By default, macOS ships with
bash as its shell prompt. While bash is certainly capable for many use cases, it lacks modern usability features and is quite rudamentary. Put bluntly, it’s not very Mac-like. When you spend a lot of time in the terminal, you can be a whole lot more productive by switching your shell to
fish. You’ll quickly realise that when you have a smart shell under the hood, the terminal takes on a whole new life. It’s quite different to bash so there’s a bit of a learning curve at first, but once you’re up and running, it’s a vastly improved experience.
Why fish? #
There are a number of reasons why fish is superior to other shells:
- It’s user-friendly, with features like syntax highlighting and auto-suggestions. Quite often fish will predict what you are trying to do after typing only a couple of characters. It’s incredible how accurate it is too.
- It’s intuitive so you don’t need to remember complicated and archaic syntax.
- It takes advantage of modern ways of operating, without being held back by trying to maintain compatibility with old systems.
- It still does the things you’re used to with support for wildcards, piping, tab completions, variables and command substitutions, just to name a few.
If you want to see more, the fish tutorial page is a great place to dive a little deeper.
Installing fish on macOS #
The fish website offers a number of ways to install fish but my preferred method is using Homebrew. If you haven’t got Homebrew on your Mac yet, check out my Getting Started with Homebrew guide before continuing.
If you’re not ready to commit just yet, you can give fish a try using a standalone fish app. Head on over to the fish website to get a copy, otherwise continue reading to get set up with Homebrew.
You can install
fish just like any other Homebrew package:
brew install fish
When the installation finishes, you’ll see a notice about adding fish to your list of shells in
/etc/shells. You’ll need to enter the following command, along with the root password when prompted:
echo "/usr/local/bin/fish" | sudo tee -a /etc/shells
Now all that’s left to do is to make fish your default shell. We use the
chsh command to do this, which will prompt for your local user account password:
chsh -s /usr/local/bin/fish
Quit and reload the Terminal app and, if everything went to plan, you’ll be greeted with your new fish prompt.
Getting Started #
One of the excellent things about fish is it’s highly customisable. There’s a few things you can do straight away so that you feel a bit more at home.
Basic Configuration #
Fish has a web-based configuration to set some basic configuration items and you can get to it by entering:
This will open your default browser to the config page where you can customise the colour scheme and default command prompt. Keep in mind that if you want to change your Terminal window’s background colour, you’ll need to edit this in Terminal > Preferences > Profiles as you can’t set the background colour directly via fish.
fish_config will also show functions and environment variables that are currently configured, although you can’t edit these items using the web interface. For now, press Return to stop the web server.
Changing the Greeting #
You’ll notice fish has a default greeting whenever you start a new shell session. If you want to remove the default notice, you can do so by entering the following command which will empty the
However, one of the great things about fish is you can also define your own custom greeting function which will be called each time you start a new session. If you want to learn more about this, check out my Making a Custom Fish Greeting guide.
I Still Need bash! #
From time to time you may find that you need to quickly run a bash command that isn’t supported in fish. You can easily switch back to bash by using:
This will start a new bash session without changing your default shell away from fish. When you’re done running your bash commands, you can simply type
exit and you’ll be returned to fish. Easy!
Further Reading #
If you’d like to learn more about using fish, you can visit the built-in documentation by running the help command:
This will open your default browser to the fish documentation. You can also visit the online documentation at the fish shell website.