Ubuntu – Gnome-terminal custom command and dynamic working directory

fishgnome-terminalUbuntu

This is kind of a followup to another question.

I use a custom command in my gnome-terminal profile (/usr/bin/fish). When using Ubuntu 14.04 a Ctrl-Shift-N opened a new gnome-terminal window in the same directory as the current terminal. With 16.04 this changed and now it always opens in $HOME. I want the old behavior.

This has nothing to do with sourcing /etc/profile.d/vte.sh. Fish does this correctly as I can observe directory changes in the title bar. If I uncheck the custom command box in my gnome-terminal profile, the new terminal window correctly uses the current directory. However, it use my system default shell: bash.

I cannot change my system shell (chsh), because this is shared across other machines, where fish is not available.

I don't see a way to fix this from fish, since the terminals current directory is not available.

Edit: Since this a regression in Ubuntu, I also reported this as #1609342 to Ubuntu.

Best Answer

As Gilles mentioned in a comment, setting the SHELL variable works as well. It does not have downside of my other answer. Here are the details:

  1. Create .xsessionrc in your home directory with contents:

    SHELL=/usr/bin/fish
    
  2. Disable custom command in gnome-terminal profile options.

  3. Log out and in again.

Gnome-terminal should respect the variable and use that custom command. It does for me on Ubuntu 16.04.1 and solves the working directory problem.

Related Question