4

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.

6
  • Which fish version does this use? Fish essentially does the same thing as vte.sh via one of its scripts, and there's been a few changes to that for fish 2.3.0, so you might want to try that.
    – faho
    Aug 3, 2016 at 13:13
  • @faho I use 2.3.1.
    – qznc
    Aug 3, 2016 at 14:25
  • 1
    You can tell Gnome-terminal what shell to launch by setting the SHELL environment variable. There's no need to change your login shell. I don't know whether that solves the working directory problem, but you don't need to use a custom command. Aug 3, 2016 at 20:26
  • Thanks Gilles, that works. I expanded this into a proper answer.
    – qznc
    Aug 4, 2016 at 7:18
  • Bug reports for features like this should be opened in gnome rather than ubuntu, since the problem is an upstream design change. Aug 4, 2016 at 8:19

3 Answers 3

3

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.

2

For those running a Wayland session, this workaround based on setting the SHELL variable will not work because Wayland does not source any shell files, incluing .xsessionc, .profile, or .bashrc.

One variation of the workaround that worked for me was to create a custom launcher for GNOME Terminal that set the SHELL environment variable with env:

env SHELL=/usr/bin/fish gnome-terminal
0

One workaround would be to add the following to .bashrc:

if [ -f /usr/bin/fish ]; then
    exec /usr/bin/fish
fi

The downside: As a fish user, you sometimes need a POSIX-compatible shell. If you execute bash the hack above will give you yet another fish shell instead.

1
  • 1
    One way around the "no bash" problem is bash --rcfile /dev/null Aug 4, 2016 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .