3

How do I set the default working directory of a gnome-terminal opened via Ctrl-Alt-T or via the Launcher or any other quick means to a gnome-terminal? Presently it defaults to ~. I know about gnome-terminal --working-directory=/path/to/dir but that's not as quick as Ctrl-Alt-T.

Note that I can't put a cd /path/to/dir in .bashrc because I also need nautilus-open-terminal to continue to open at the directory Nautilus is displaying at the time.

1
  • Note that in 16.04 when I try to install nautilus-open-terminal I get Package nautilus-open-terminal is not available. It might be obsolete. From inside Nautilus right click 'open terminal' is doing the desired operation so that package does not seem necessary anymore.
    – H2ONaCl
    Feb 12, 2017 at 18:04

1 Answer 1

4

If editing .bashrc is not an option, there are various alternatives:

1. Edit the Exec= line of your launcher:

  • Copy the global gnome-terminal.desktop file to ~/.local/share/applications

    cp /usr/share/applications/gnome-terminal.desktop ~/.local/share/applications
    
  • Open the local copy with gedit:

    gedit ~/.local/share/applications/gnome-terminal.desktop
    
  • Look up the first occurrence of the Exec= line, change it into:

    Exec=gnome-terminal --working-directory=/path/to/your/directory
    

    where the path needs to be a full path.

  • Either Log out and back in, or run source ~/.profile.

    Now when you click on the launcher or run gnome-terminal from Dash, it will open a terminal in your directory. The right-click option will work as usual. Ctrl+Alt+T however will still take you to your home directory.

2. Create a new shortcut

Add the command gnome-terminal --working-directory=/path/to/your/directory to a shortcut key: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

gnome-terminal --working-directory=/path/to/your/directory

Use full path here.

3. Add a quicklist -item to your gnome-terminal launcher.

  • Copy the global .desktop file locally and open the local copy, as in [1.]
  • Look for the line:

    Actions=New;
    
  • Change it into (in my example)

    Actions=New;Open terminal in Documenten;
    
  • To the very end of the file, add a section:

    [Desktop Action Open terminal in Documenten]
    Name=Open terminal in Documenten
    Exec=gnome-terminal --working-directory=/home/jacob/Documenten
    OnlyShowIn=Unity;
    

    enter image description here

4. Change the functionality of Ctrl+Alt+T

If you'd insist on using the shortcut Ctrl+Alt+T to open the terminal, first disable the current shortcut, by running the command:

gsettings set org.gnome.settings-daemon.plugins.media-keys terminal ""

This will make the shortcut Ctrl+Alt+T available as a custom shortcut. Then add the command

gnome-terminal --working-directory=/path/to/your/directory

to Ctrl+Alt+T. Again: use a full path here.

2
  • I would have expected the last one was your favourite, since it uses Ctrl+Alt+T :) Jan 11, 2016 at 8:22
  • I like the first suggestion. In the same file Actions=New is associated with another exec variable and the same --working-directory can be set there.
    – H2ONaCl
    Mar 12, 2017 at 6:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .