Prevent gnome-terminal from changing directory when creating a new tab or window

If I have changed directory in gnome-terminal away from $HOME, to i.e. $HOME/foo, then create a new tab or window, this new tab or window will have $HOME/foo as the current working directory instead of $HOME. This is new and alien to me and I prefer the old, standard behaviour of all new terminal instances being in $HOME.

I would like to acheive this without modifying my user's .profile or .bashrc (with a cd line or whatever). I am running gnome-terminal 3.18.3 on Ubuntu 16.04.


Solution 1:

I get it work by setting a custome command in profile settings, command tab.

From top menu: Edit -> Profile Preference.

Then command tab, check the Run custom command instead of my shell and set /bin/bash as your custom command.

To run the default shell instead of bash use:

/bin/sh -c '`/usr/bin/getent passwd $USER | cut -d: -f7`'

instead /bin/bash as your custom command.

enter image description here


I'm not sure what is the cause of problem, However I thing each time you create a new tab gnome-terminal forks your current instance, so it's going to inherit your old tab's working directory, but when you set a custom command it's going to create a new instance each time.

Thats only what I think is happening here.