Gnome-terminal tabs not opening in current directory

Hi, how can i make it so that opening a new tab in gnome-terminal does NOT open it in my $HOME directory but rather in the one i’m already working in? Apparently this should be the default behaviour but that does not seem to be the case on my machine, even with ‘preserve working directory’ set to ‘always’ in gnome-terminal settings. I’m on Fedora 37, Gnome Shell 43.3, Gnome Terminal 3.46.8.

Here’s my .bashrc and .bash_profile.
I can’t think of anything else that could be overriding the default behaviour?

Please correct me if my understanding is wrong:

  1. Start Terminal from GUI. The current directory in the shell is ~
  2. cd somedir
  3. create a new (2nd) tag - you want that new window having ~/somedir as current directory
    (indeed, this is the behaviour I am having)

I further test:
tag 1: pwd is ~/.ssh

  • add new tag when tag 1 is active, new tag pwd is ~/.ssh
    tag 2: pwd is ~/.config
  • add new tag when tag 2 is active, new tag pwd is ~/.config

ps. My “Preserve working directory” is “Shell Only” . That should be the default, as I never changed it.

You understood correctly. If i’m in ~/.ssh and press ctrl+t to open a new tab, the directory of the new tab is ~. Ideally I would want to be able to open a new tab [ctrl+t] in the same directory and a new window [ctrl-n] in my home dir (this last case is the current behaviour for both cases).

Neither ‘shell only’ or ‘always’ seem to change the behaviour.

You can isolate the issue by testing from a new user with default profile settings.

1 Like

Hi, sorry for the late reply.
I tried creating a new user through Gnome’s settings and the problem seems to persist to the new user also. The directory jumps to $HOME when opening a new tab.
Is there any setting that could be working at a ‘system level’ and not for single users (pardon if this is not the right terminology)?

This is a bit tricky, assuming your shell is bash:

# List all related configs
find /etc/bash* /etc/profile* /etc/skel | sort

# List packages owning configs
rpm -q -f $(find /etc/bash* /etc/profile* /etc/skel) | sort -u

# List modified and extra configs
sudo rpm -V -f $(find /etc/bash* /etc/profile* /etc/skel)

The default fedora .bashrc appears to work correctly on my machine.
If I remove my prompt customization from my bashrc it also works.

edit …
after playing with this a little bit if I change

This appears to work.

_build_prompt is a function to define PS1, the only dynamic parts are for git and command status.