0

Several times a day I need to open my development environment by opening a terminal window (the default xfce4-terminal) and typing the following commands:

cd ~/Desktop/xyz
conda activate tf_gpu

I want to automate this process with a shell script that I can double-click. I've seen lots of similar questions but none of the answers open the window for me.

Not sure if it matters, this is on Linux Mint 20.1.

I've tried putting the following files on my Desktop with "Allow this file to run as a program" ticked in Permissions.

  1. This seems to do nothing:
#!/bin/bash
cd ~/Desktop/xyz
conda activate tf_gpu
  1. This:
#!/bin/sh
x-terminal-emulator -e "cd ~/Desktop/xyz && conda activate tf_gpu"

throws the following error:

Error
Failed to execute child
Failed to execute child process "cd" (No such file or directory)
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Joooeey
  • 123

1 Answers1

0

I manage to do it with lxterminal, this should work with xfce4-terminal as well

  1. create helper file .start in ~/Dektop/EDEO-Sensing

    conda activate tf_gpu ## see note a)
    bash -i
    
  • must be executable

a. you might need to change to . conda activate tf_gpu

  1. edit a .desktop with

    [Desktop Entry]
    # VERSION=3.36.2
    Name=Terminal-Test-UL
    

    my test : Exec=lxterminal --working-directory=tmp7 -e './.start'

    Exec=xfce4-terminal --working-directory=~/Dektop/EDEO-Sensing -e './.start'

  • best method is to open xfce4 terminal and ask for a copy to desktop, then edit file with revelant information.
  • use GUI to "allow for execution" on desktop file.

you will have to fiddle with it in each ubuntu major release

Archemar
  • 31,554
  • How do I run 2. with a double-click? Note that this suggestion is not shorter than what I have to type now. – Joooeey May 31 '21 at 11:35