Fish advertises itself as a smart and user-friendly command line shell for OS X, Linux, and the rest of the family. If you’re using bash, I highly recommend reading this post and trying fish.
Colors out of the box
Valid command (blue) vs invalid command (red)
Autosuggestions based on history
Man page completions
brew install fish
Preferences(Command + ,)
- Find the text label
Shells open with:
- Click on
Alternatively you can change it via the command line:
chsh -s /usr/local/bin/fish
Make sure the file path matches the location of the fish executable on your machine.
Fish provides a web interface that enables some extra configuration. Simply type
fish_config inside your shell and hit enter.
A browser should open (
localhost:8000) with a website that allows you to perform certain configuration tweaks discussed below.
Change default colors
Change the prompt
The prompt function is defined here:
~/.config/fish/functions/fish_prompt.fish. There are various pre-defined prompt functions you can pick from, or you can create your own.
My prompt function is inside this gist. It may look a bit strange that commands are written in a second line. However, since my terminal usually takes up more space vertically than horizontally I prefer it. There’s also a blank line between each command to help improve readability. If you’re inside a git repository folder it should also display the name of the branch you’re on.
Functions in fish wrap common shell tasks. For example, I created a new file:
~/.config/fish/functions/gs.fish with the following:
function gs --description 'alias for git status' git status -s $argv end
Now every time I type
gs into the terminal it will run
git status -s.
The example above is just a simple alias, but hopefully it illustrates how easy and useful it can be to create functions.
It’s possible to set environment variables using the following syntax:
set -x greeting hello. You can view some variables using the web interface.
If you found this post useful or have questions, send a tweet or leave a comment. Feel free to show off your prompt, functions or anything fish related in the comments.