Score:1

open only new terminal window in custom directory

ru flag

I'm opening the terminal by pressing Window + 2. I want that to open in ~/some-custom-directory

Thing is, I want new tabs within the terminal window to NOT be affected by this behavior, i.e. if I'm in ~/other-directory and open a new tab, I want it to open in the same directory ~/other-directory, and not default to ~/some-custom-directory

Is this possible? Can I change the behavior of opening a terminal window without it affecting opening a terminal tab?

PonJar avatar
in flag
I don’t think you can do that with a single key combination. However you should be able to do it with two different key combinations. e.g. Windows+2 for the custom directory and some other combination for a new tab
Score:2
cn flag

It already works like you wish by default.

  • You can specify a different startup directory with the option --working-directory, e.g. gnome-terminal --working-directory ~/some-custom-directory
  • When you open a new tab, the new tab will always default to the current directory of the active tab, i.e., if you are in ~/other-directory, a new tab will also open in ~/other-directory.

To have that work for the shortcut key Super+2, which launches or switches to the application that is the 2nd favorite on your dock (in your case, that is the terminal), edit the .desktop launcher involved.

  • Copy the desktop launcher of Gnome terminal (/usr/share/applications/org.gnome.Terminal.desktop to your local applications directory (~/.local/share/applications).
  • Edit that local copy of the .desktop file and add the option to the command in the Exec= line. Note that here, you need to indicate the full path name, because bash expansion (~) or variable substitution (e.g. $HOME) does not work in .desktop launchers. The customized copy will take precedence over the default one, so within seconds, your shortcut key should launch your terminal in the directory of your choice (of course, only if Terminal was not running - if it is running, the shortcut key will only bring the running instance forward without changing directories).
ru flag
`--working-directory ~/some-custom-directory` didn't work, neither did `--working-directory $HOME/some-custom-directory`, what did work is `--working-directory /home/MY_USER_NAME/some-custom-directory`. Change your answer to that and I'll accept it :)
vanadium avatar
cn flag
Indeed, bash expansion does not work in .desktop launchers. I added a warning for those unaware.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.