Gnome-terminal: how do you set working-directory

gnome-terminal

This has been bugging me for years. The terminal starts up in~/Desktop (up to 20.04, anyway), which is completely useless. How do I fix this? What I know so far:

  1. It doesn't start in the current directory, so any changes to .bashrc/etc won't help. ~/Desktop behaves almost as if it's compiled into the app
  2. There are no dconf settings (/org/gnome/terminal/legacy/profiles) related to setting working-directory
  3. You can't set in the profile for a given terminal
  4. You can't set it by editing the Exec string in /usr/share/applications/org.gnome.Terminal.desktop – it doesn't work

If you already have a terminal open, then this does work:

$ gnome-terminal --working-directory=$HOME

But if you change any/all of the Exec strings in /usr/share/applications/org.gnome.Terminal.desktop, it makes no difference:

Exec=gnome-terminal --working-directory=$HOME

This last one is known to work in RHEL.

Update:

  1. A desktop icon starts up in my home directory, when there is no working-directory in the Exec setting

  2. CTL-ALT-t starts up in my home dir, presumably using the global settings in /usr/share/applications/org.gnome.Terminal.desktop

  3. Desktop right-click always starts up in ~/Desktop, per vanadium's comment

  4. update-alternatives output is

    $ update-alternatives –display x-terminal-emulator
    x-terminal-emulator – auto mode
    link best version is /usr/bin/gnome-terminal.wrapper
    link currently points to /usr/bin/gnome-terminal.wrapper
    link x-terminal-emulator is /usr/bin/x-terminal-emulator
    slave x-terminal-emulator.1.gz is /usr/share/man/man1/x-terminal-emulator.1.gz
    /usr/bin/gnome-terminal.wrapper – priority 40
    slave x-terminal-emulator.1.gz: /usr/share/man/man1/gnome-terminal.1.gz

Best Answer

It will work if you explicitly spell out the directory instead of specifying $HOME. Reason: desktop launchers do not support bash variables or bash expansions.

Related Question