I do not like to retype fish every time I start terminal. I want Fish on by default. How can I set the Fish shell as my default shell on a Mac?
I do not like to retype fish every time I start terminal. I want Fish on by default. How can I set the Fish shell as my default shell on a Mac?
You can use chsh to change a user's shell.
Run the following code, for instance, to change your shell to Zsh
chsh -s /bin/zsh
As described in the manpage, and by Lorin, if the shell is not known by the OS, you have to add it to its known list: /etc/shells.
Here's another way to do it:
Assuming you installed it with MacPorts, which can be done by doing:
sudo port install fish
Your shell will be located in /opt/local/bin/fish.
You need to tell OS X that this is a valid shell. To do that, add this path to the end of the /etc/shells file.
Once you've done this, you can change the shell by going to System Preferences → Accounts. Click on the Lock to allow changes. Right-click on the account, and choose "Advanced Options...". In the "Login shell" field, add the path to Fish.
On macOS v10.14 (Mojave) I had to do the following (using Z shell (zsh) as an example):
brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)
How to get the latest version of Bash on modern macOS (tested on macOS v10.14 (Mojave)).
brew install bash
which bash | sudo tee -a /etc/shells
chsh -s $(which bash)
Then you are ready to get Vim-style tab completion which is only available on Bash >= 4 (the current version in Homebrew is 5.0.2):
# If there are multiple matches for completion, Tab should cycle through them
bind 'TAB':menu-complete
# Display a list of the matching files
bind "set show-all-if-ambiguous on"
# Perform partial completion on the first Tab press,
# only start cycling full results on the second Tab press
bind "set menu-complete-display-prefix on"
fish to check if it was installed correctly, if installed correctly, type exitwhich fish, copy the path.sudo sh -c 'echo <your-fish-path-here> >> /etc/shells'chsh -s <your-fish-path-here>Homebrew on M1 Macs should use /opt/homebrew instead of /usr/local.
You can check the Fish location which fish. For me, Fish was in /opt/homebrew/bin/fish which was the location I have added to etc/shells.
The chsh program will let you change your default shell. It will want the full path to the executable, so if your shell is Fish then it will want you to provide the output given when you type which fish.
You'll see a line starting with "Shell:". If you've never edited it, it most likely says "Shell: /bin/bash". Replace that /bin/bash path with the path to your desired shell.
Use dscl:
heimdall:~ leeg$ dscl
Entering interactive mode... (type "help" for commands)
> cd /Local/Default/Users/
/Local/Default/Users > read <<YOUR_USER>>
[...]
UserShell: /bin/bash
/Local/Default/Users >
Just change that value (with the write command in dscl).
In case you are having troubles with the other ways, the following worked on macOS v10.14 (Mojave), but it should generally work.
which fish
Add the output path to System Preferences → Users & Groups → right click user, Advanced Options. Paste the result from which into filed "Login shell:".
To change your default shell on Mac, run the following:
chsh -s <name-of-shell>
The list of shells you can choose from are:
so if you want to change from to the /bin/zsh shell, your command will look like:
chsh -s /bin/zsh
You can see all the available shells on your system by running:
cat /etc/shells
Edit file .zshrc and change it to
exec /bin/bash
Or to whatever shell you might prefer.
Bonus: this doesn't require root access and will work on every version of OS X.
The only problem is that it doesn't read file .bash_profile this way; it is only read if Bash is run as an interactive login shell. You would have to include it from file .bashrc with something like this:
if [[ "$OSTYPE" == "darwin"* ]]; then
#local hack on osx.
if [[ -f $HOME/.bash_profile ]]; then
. $HOME/.bash_profile
fi
fi
Also: The bash version that comes with osx is a bit dated, it is preferrable to install an up to date version of bash with brew install bash; in this case your .zshrc file should run the correct bash version. Currently that is
exec /usr/local/Cellar/bash/5.1.8/bin/bash