7

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.

  • What's wrong with using the plugin for your file manager that does this? – Ignacio Vazquez-Abrams Jan 22 '13 at 18:46
  • Which terminal program are you used to (xterm, urxvt, gnome-terminal, etc)? – user1146332 Jan 22 '13 at 19:10
  • 1
    @user1146332 think it's gnome-terminal. The one found on Linux Mint Menu called 'terminal' (similar to the Windows XP start menu) – damx Jan 22 '13 at 19:16
  • @IgnacioVazquez-Abrams Not sure what you mean by "plugin for your file manager" but if you mean going to the specifici folder/directory via Thunar (think that's what it's called), right clicking and clicking on "open terminal here", then it requires too many clicks. I would rather just type the CD commands from the terminal. I am just looking for a faster way so I click a button/shortcut from the desktop, it automatically opens a terminal and takes me to a specific directory. Trying to stay in the ternminal environment since I run some commands – damx Jan 22 '13 at 19:24
6

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)
  • Where do I enter that command? Rather, how do I create a desktop shortcut? – damx Jan 22 '13 at 19:40
  • I don't use mint nor i use gnome currently. But i remember that you have to right click on the desktop and create a launcher. A window with several entries pop's up. There must be one entrybox in that window where you have to put the command. – user1146332 Jan 22 '13 at 19:49
  • 1
    Wow, it works perfectly! ^^)/ yatta! Thanks user1146332. Hope you don't mind me revising your answer a bit and adding the specific steps I took in case others might find useful. Thanks again. – damx Jan 22 '13 at 19:53
  • I'm glad to see that it's working for you. Feel free to revise my answer (but maybe your reputation count isn't sufficient for this yet) – user1146332 Jan 22 '13 at 19:58
0

Create a file named 'something.desktop' and add the following code. If you are familiar with the commands on launching the 'something.desktop', it will list all the files in the home directory in a terminal.

And, make sure to make 'something.desktop' executable. Fro making any file executable the code is -

chmod +x /path/to/your/something.desktop

Edit it with your own values

[Desktop Entry]
Type=Application
Name=IPT
GenericName=IPT
Comment=IPT Desktop icon developed by Mritunjay
Categories=Network;Security;
X-KeepTerminal=true
Icon=/usr/img/ip.png
Exec=gnome-terminal --tab --title="List files" --command="bash -c '/home; ls; $SHELL'"

NoDisplay=true

Hope it helps!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.