Linux – How to make a Desktop “shortcut” that opens the terminal but under a different directory than the default home

command linedesktop-shortcutsdirectorylinux-mint

Objective

I am looking for an easy way to consistently run a terminal that automatically opens to a specific directory. Is there a way to do that without changing the default directory?

Preferably I just click on a 'shortcut' link and it opens that customized terminal to that directory or maybe runs the CD command for me.

Full Story

Currently, when I open the terminal (via the Linux Mint GUI menu) it by default 'takes' me to the home directory. This is a fine default choice for the majority of times.

However, there are instances where I wish it would open elsewhere. I don't wish typing the CD command every time, for example:

cd Dropbox/GTD

Since I go to work on the files located on that specific directory every now and then (enough to be a pain), I am hoping someone can point a way so all I do is ideally

  1. Click on a desktop shortcut (script or whatever mechanism)
  2. Terminal opens under that specific directory without me typing any commands.
  3. I can instantly work on the files located there.
  4. If I open another terminal outside that 'shortcut', the terminal opens to the default home directory like usual.

I have a basic understanding working with the command line and Linux in general but am not advanced. Hopefully, you can dumb it down a bit ^_^

Oh and thanks in advance for any tidbits that can help point me in the right direction.

Best Answer

Most terminal programs like xterm, urxvt, gnome-terminal have an option to change the starting working directory of the shell.

If you are using gnome-terminal, there is a special command line switch you have to provide to start the shell in a user defined directory. The command line switch I'm talking about is

--working-directory=DIRNAME

You should take a look at the manual pages of gnome-terminal to verify this.

So, if you want to make a desktop shortcut, the command you have to enter would be:

gnome-terminal --working-directory=/home/you_username/Dropbox/GTD

Beforehand feel free to test the command in your current terminal session.


For users on Linux Mint, follow these instructions

  1. Right click on the Desktop
  2. Select "Create Launcher"
  3. Name this shortcut with whatever name you want
  4. In the Command field, enter gnome-terminal --working-directory=XXX. Make sure to replace XXX with the directory you want it to go to (see the example above)
Related Question