fish shell

With the release of macOS Catalina Apple have decided to finally do something about the very out of date version of Bash they ship. By changing the default to zsh which is one way to deal with licencing issues I suppose. Users of the excellent Homebrew could already install a current version of Bash. But there are more shells in heaven and earth, Horatio, than are dreamt of in your philosophy1. So with Homebrew2 installed and a cavalier attitude to changing one of my primary interfaces for dealing with my computer I've decided to give fish shell a run.

Installation

brew install fish
echo /usr/local/bin/fish | sudo tee -a /etc/shells
chsh -s /usr/local/bin/fish

This installs fish, adds it to the shell database, and then changes your shell to that. The next terminal window you open will be a shiny3 new fish shell.

Configuration

fish is pretty nice out of the box but some customisation will make it a bit more personal. Let's start by installing Oh My Fish.

curl -L https://get.oh-my.fish | fish

Once the random script downloaded from The Internets4 has finished running on your machine you'll have the omf command available. This installs and manages packages that customise the shell. Let's install the bobthefish theme and the brew plugin.

omf install bobthefish brew

Once that's done we can apply the theme with:

omg theme bobthefish

To make the most of this theme a new font is in order. You'll need a Powerline font. Homebrew has a cask with a variety of options so let's tap that and install one.

brew tap homebrew/cask-fonts
brew cask install font-meslo-nerd-font

By installing a nerd variant we also get a lot of nice icons that will make things a little more fancy. Once the font is installed configure your terminal to use it. If you use iTerm25 this can be done in Preferences -> Profiles -> Text. Most fonts install a few options so you can experiment to find an option you like.

To make the theme use the nerd font extras run:

set -g theme_nerd_fonts yes

If you want that to apply permanently add it to ~/.config/fish/fish.config6.

Helper functions

I'm slightly obsessed with running the latest version of things. But I'm also kind of lazy. What I want is a simple way to update a lot of things with a minimum of keystrokes. Let's define a function to do that.

function update-all
  brew update && brew upgrade && brew cask upgrade && brew cleanup
  omf update
end

This function runs a number of Homebrew commands to update all my Homebrew packages and clean up old versions then uses Oh My Fish to update fish packages. Functions placed in ~/.config/fish/functions/ become available to use automatically so let's save it there as update-all.fish7. Now if I run update-all all my Homebrew and fish packages will be updated.

Next steps

There are a number of additional things I still want to do with my fish configuration:


  1. I hated every second of English Literature in high school and quote this here only out of spite. ↩︎

  2. If you don't install Homebrew on every Mac you own then you are bad and you should feel bad. Why not give them some money via Patreon. ↩︎

  3. Shininess not a guarantee. Offer void where prohibited. ↩︎

  4. What could possibly go wrong? ↩︎

  5. Use iTerm2 ↩︎

  6. Create it if necessary. Did you really need a footnote to tell you this? ↩︎

  7. It is fish convention to give the file the name of the function and horrors await if you break it8. ↩︎

  8. I did not test what happens ↩︎