Why I use Fish Shell over Bash and Zsh 🐟
July 03, 2019
The things that make Fish great, the caveats and which (few) plugins you need to complete the experience.
One of the main allurements of Apple is that things “just work”. Most of the people who use their products are covered with the features they release and Apple spends little time on anything else. The features they do ship, are polished, have sensible defaults, and are intentional. This is what I believe the Fish shell has become. No wasted time scouring the web for config files others have shared, the best plugins to use, or how to get integrations working with your particular setup.
This shell is meant for most people, Fish stands for Friendly Interactive Shell, that’s why I can recommend it to anyone I work with. They have a very detailed design document. It’s not meant for the likes of system admins who are constantly logging into multiple servers a day. It will never be the default installed shell on most operating systems.
Once you install it,
brew install fish, you are off to the races. You have a shell where you can become super productive and your favourite tools work as intended. It doesn’t try to be the best at everything, but nails the essential core features which make the user experience extremely enjoyable.
- Syntax highlighting
- Inline auto-suggestions based on history
- Tab completion using man page data
- Intuitive wildcard support
- Web based configuration
Let’s break it down
My worst memories of bash come from the absence of this feature, syntax highlighting. A simple thing which makes you think, “wow, now I am using a shell from the 90’s”! You can notice it working in the below gif when I try to go to
folder_that_doesnt_exist, the text turns red. The text then turns blue when it’s a valid command.
Inline auto-suggestions based on history
Smart auto-suggestions are seldom seen, let alone built-in. Instead of just beating the competition, the Fish team thought to demolish it. Using the history of your commands, it suggests commands which you can complete with the
right-arrow key. You can also, as I do this gif, auto-complete one word or folder at a time with
option + right-arrow key.
Fun fact, if search results are huge, Fish shell will paginate!
Tab completion using man page data
This is because Fish knows how to parse CLI tool man pages in many different formats. Git, Docker CLI, package.json, you name it, most commands you try, it will have auto-completions for it.
You can use
tab to get all the options.
Intuitive wildcard support
In bash, I never liked having to use different flags for selecting files or contents of a folder.
Regularly, this would be done with:
rm -r folder_1
I have always been a fan of familiarity, and wildcards are just that. You can use them in any command filter down the exact files you need with ease.
Web based configuration
and you get an entire website dedicated to messing around with any config you do need to touch.
A tiny customization needed to go the extra mile
There aren’t a lot of extra packages needed for Fish. Personally, I only use 2, which is wild because at one point I know my Oh-My-Zsh plugins were past 10.
Oh My Fish
Special mention to Spacefish for being the best shell prompt I have ever used. Support for showing:
- Current Git branch and rich repo status
- Current Node.js version, through nvm
- Package version, if there is a package in the current directory (package.json for example)
You also have access to a config file at
.config/fish/config.sh. This is where you can set aliases up or set some extra path extensions.
exit and then come back to Fish when I finish. This Stackoverflow post goes into it more if you are so inclined.
But it’s easy to be compatible…
Say you have a bash script to run, with Fish you still can:
Another tip is that you can put this at the top of the file:
and then make sure its an executable:
chmod +x script.sh
and voila, you can run it as a regular script:
- Fish Shell Website
- Fish Shell Syntax Highlighting
- Fish Shell Autosuggestions
- Try out the Fish Shell tutorial online
- Oh My Fish Package Manager
- NVM wrapper plugin
- Spacefish Fish Shell Theme
- List of awesome Fish related software
- Support Bash scripts in Fish