Switching to Fish Shell on macOS

Fish Shell on macOS with Ghostty Terminal

I was recently listening to the Fallthrough Podcast with Mitchell Hashimoto of Hashicorp fame (yes, I'm admittedly a little behind) on using Zig for writing the Ghostty terminal. During the podcast, one of the hosts, or Mitchell?, talked about using the Fish Shell. While I have been a long time ZSH user, specifically OhMyZsh, before it was the default on macOS I decided to give it a try.

However, I found it rather difficult (some of this was PEBKAC*) to change my shell from ZSH to Fish on macOS and discovered a few new things along the way and thought it was worth sharing.

Why Fish Shell?

The first reason I wanted to try Fish as my default shell was out of curiosity. However, as I started to look into the features it started to appeal a little more. A lot of this research was done on YouTube reviews and this short list is not going to deviate from those lists.

  1. Web UI for settings - fish_config is built in by default and when called it will open a web UI for managing your settings for your shell including themes, prompts, variables. This is pretty awesome and I'm a fan of making things simple for users - regardless of experience level. If you don't like the UI, you can still pass arguments to fish_config (which the UI will expose in the terminal when modifying the config)
  2. Syntax Highlighting - when typing commands, changing directories, etc. Fish Shell gives you instant feedback (changing to the input to red by default) when you type a command that does not exist. This is a small thing but a nice quality of life feature
  3. Private Mode - as someone who is constantly sharing and demoing on my computer, there are times where I would like the history of commands to not be remembered, or maybe appear as a new terminal session with no history. This is useful for tutorials where I want what I am showing to closely match what the user is going to see as well

Installing Fish Shell

I use Homebrew on macOS and have for years, so installing Fish was as simple as running brew install fish and wait for the installation.

To verify fish is installed, you can run type fish and you should get something similar to /opt/homebrew/bin/fish.

You have successfully installed Fish Shell! 🎉

Changing your default shell

This is where I ran into a few issues and discovery that are worth sharing.

The first thing you need to do is change your default shell using the following command:

chsh -s /opt/homebrew/bin/fish

You are most likely going to see the following output and assume it was successful:

chsh -s /opt/homebrew/bin/fish

chsh: /opt/homebrew/bin/fish: non-standard shell

Not seeing an error is quite confusing and I tried multiple times to restart my terminal to see if the change would take but nothing was happening.

It turned out, this is a security setting in macOS, and it is rather unhelpful. The term non-standard shell means that fish (in this case) is not in the list of allowed login shells. To fix this I needed to add fish as an allowed shell in /etc/shells by running the following command:

sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'

Then, I ran the command to change the shell again:

chsh -s /opt/homebrew/bin/fish

This time I did not see the message about non-standard shell so I assumed I was good. However, I was completely wrong as before I found the right path to fish, I did a copy-pasta and set my default shell to a path that does not exist and could not open a terminal session to correct 🤦. This led to a new "hidden" feature in macOS settings.

Fixing a broken default shell on macOS

While I'm sure there are other ways to do this, I felt like this hidden Advanced Settings should be documented. One of my biggest pain points on macOS is the amount of hidden junk and ctrl clicks it takes to find settings; this is one of them.

I discovered this option on this SuperUser post for complete credit.

To get to the Advanced User Setting on macOS, perform the following:

💡
WARNING: This settings page has features that can break your account, so proceed with caution.
  1. Open Settings
  2. Search for "Users" and go to Users & Groups
  3. When you see your username, ctrl click on your photo, this should open a menu popover with the "Advanced Settings"
  4. Here you look for Login shell and switch back to the default (e.g. ZSH) and restart your terminal to get access again.

Here is a quick video on navigating to this setting if it's easier for you 👇.

0:00
/0:17

Fish Shell

Assuming you did everything correctly, unlike me, you should be able to restart your terminal to a new Fish Shell - happy terminal-ing!

🥳 🥳 🥳

References

If you are looking for a decent overview video, check out this video from BetterStack on Fish Shell:

*PEBCAK stands for Problem Exists Between Keyboard And Chair