How to install and configure fish shell on macOS via homebrew.
This is mostly for my future self to reference, but just in case anyone else finds it useful, here is how I setup fish shell on macOS.
brew install fish
chsh -s /usr/local/bin/fish
- [Recommended] Create config directories and files:
mkdir -p ~/.config/fishand
touch ~/.config/fish/config.fish. This config file will be used for other optional installs such as Starship, below.
mkdir -p ~/config/fish/conf.d. Any files placed in this directory will automatically be sourced by fish on startup. I have my abbreviations (abbr) and oh-my-fish files here.
- Remove intro to fish message:
- [Optional] Enable vi keybinds
- [Recommended] Install oh-my-fish
- [Recommended] Install Starship prompt
- text-replacement style aliases (abbr)
- rich autocomplete via man page parsing
- It’s something new and different. I’ve used (in order): csh, tcsh, bash, zsh. Those all feel like the same family. Fish feels like something totally different. A little less UNIX-y and a little more… python-y?
- Terminal.app spawns bash shells on every command for some unknown reason. Use iTerm2 instead. I’ll eventually have to solve this one. I prefer the built-in apps unless there is a very large feature gap to third party solutions. (iTerm2 arguably is exactly that)
- Fish is not POSIX compliant; this was known before installing. It is just something to be aware of. Use
/bin/shfor most scripts anyway.
- Does not support escaping commands. I have a few commands that I like more modern, feature-rich versions of (cat –> bat, top –> htop, vim –> nvim) but there are times where you want the plain old version executed. In zsh, I can escape the command by prepending backslash:
\cat .zshrc. Fish won’t recognize that syntax so I have to edit my abbreviation replacement.
- All terminals (not just Terminal.app) were spawning zombie bash shells (on macOS) and sh (on Pop! OS)
- Tracking down the cullprit: omf plugin for fasd. Removing it fixed the per-command-zombie process!
- Dotfiles - I like to maintain all my settings in a dotfiles repository for easy deployment and versioning. Fish and Oh-My-Fish are no exceptions. All of the fish settings are in
~/.config/fishand omf reside in
~/.config/omf. Make sure those are versioned for easy deployment.
- I’ve added the following omf plugins:
bash ❯ omf list Plugins bang-bang fzf.fish git-flow osx xcode fish-spec git omf tab