6

I'm trying to set fish as my default shell. It's installed on the system through apt-get and is listed in /etc/shells:

> which fish
/usr/bin/fish
> grep fish /etc/shells
/usr/bin/fish

I used chsh to switch from Bash to fish:

> chsh -s /usr/bin/fish

And my default shell has been changed in /etc/passwd:

> grep "myusername" /etc/passwd
myusername:x:1000:1000:Oh Spite,,,:/home/myusername:/usr/bin/fish

Awesome. Then I logged out and rebooted. Login shells (e.g., virtual TTYs and SSH) now start fish.

And yet, when I start a terminal with either gnome-terminal or urxvt, a bash session is started. Additionally, the SHELL variable is still set to /bin/bash.

Interestingly, Terminator does use fish as the default shell. But even in that session SHELL is set to /bin/bash. If I start urxvt from Terminator, urxvt starts a Bash session.

What else do I need to do to change my default shell to fish?

(See also this question, but this is not a duplicate because I have followed those instructions and rebooted. Many times now.)

4
  • Is your final target to start fish as the default shell for terminal ? also whats the output of getent passwd myusername now ?
    – heemayl
    Aug 18, 2015 at 21:33
  • @heemayl Yes, having fish as the default shell is my goal. The output of getent passwd myusername is exactly the same as the grep output in the question (I forgot about getent.)
    – ohspite
    Aug 18, 2015 at 21:36
  • What happens if you login from the TTYs?
    – muru
    Aug 18, 2015 at 22:22
  • @muru Oh yes, I should have mentioned that login shells (virtual TTYs and ssh sessions) do start fish and SHELL is set to /usr/bin/fish in them. It is non-login shells that start Bash (except for Terminator).
    – ohspite
    Aug 18, 2015 at 22:46

2 Answers 2

5

Most terminals (at least gnome-terminal, urxvt, and XTerm, for example) that are started within a desktop environment such as Unity will use the SHELL environment variable to select the shell when they are launched.

SHELL should automatically be set to your default shell listed in /etc/passwd, but the variable can be overwritten when you log in. Make sure you have not set SHELL=/bin/bash or something similar in a file that will affect your entire desktop session. Such files include:

  • ~/.profile
  • ~/.pam_environment
  • /etc/environment
  • maybe some other files edited by Ubuntu users less often, such as /etc/profile

Additionally if any scripts such as ~/.bashrc or ~/.bash_profile are called by those other startup files and there is an export SHELL=/bin/bash line, that will also affect the entire desktop session.


I know it's acceptable/encouraged, but I still hate answering my own question. Nevertheless, this may be of some use to someone in the future. Thanks to @heemayl and @muru for helping me investigate.

3
  • Was SHELL overwritten by one of those files in your case?
    – muru
    Aug 19, 2015 at 0:56
  • 1
    @muru It was. And me listing all of the options where it can happen is an attempt to be helpful to future readers, but also a smokescreen to try to cover my embarrassing oversight.
    – ohspite
    Aug 19, 2015 at 1:06
  • @ohspite, care to share how or why your SHELL was overwritten? No matter how "embarrassing" this is it might be helpful to know a circumstance where this happen
    – MestreLion
    Nov 1, 2019 at 6:05
1

To set fish as the default shell for gnome-terminal, from gnome-terminal go to :

Edit > Profile Preferences

then go to Title and Command tab, you will get :

before

Change it as :

after

Now whenever you start a new instance of gnome-terminal, fish will be started instead of bash.

3
  • Thanks heemays. This would work for gnome-terminal, but I'm trying to set fish as the default shell for my user on the system, not for a particular application. In fact, I'm tempted just to put exec fish at the top of my Bash startup script, which would work for any terminal, but that shouldn't be necessary; I'm trying to figure out how to do it the proper way.
    – ohspite
    Aug 18, 2015 at 21:51
  • @ohspite Your login shell is set to fish, but some applications may use bash ecxplicitely, you need to change manually for those..also note that there are differences between login and non-login shells anad the files they read while starting..your question does not seem properly directed now..could you please elaborate where/in what applications you are having problem with fish ?
    – heemayl
    Aug 18, 2015 at 21:56
  • Thanks for helping me focus the question. I don't think each application needs to be set up independently; for example, man urxvt says by default the SHELL environment variable will be used. Perhaps the narrower question is "why is SHELL not set to the value in /etc/passwd after logging in", but that's not my true question so I was trying to avoid an XY problem.
    – ohspite
    Aug 18, 2015 at 22:54

You must log in to answer this question.

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