Why I use Fish Shell over Bash and Zsh ๐ŸŸ

Out-of-the-box features make Fish a breeze to use

ยท

5 min read

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.

TLDR

  • 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

Syntax highlighting

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.

All npm scripts for this package, with values of what they actually run, IN THE TERMINAL WUT
example-of-fish-shell-tab-complete

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.

e.g.

ls *.jpg
How I feel while using Fish

Web based configuration

Type in:

web_config

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

A homage to the great Oh My Zsh, omf is the most popular package manager for Fish. I use this to install just two packages, one for nvm and one for spacefish.

SpaceFish

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)
Spacefish example
spacefish-shell-prompt-example

Config file

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.

Caveats

Not being POSIX compliant can scare some developers away. But really in my three years of usage (mostly Node.js, javascript, ruby, e.t.c.), I have not encountered any issues. Some commands I get from the internet which are Bash specific, I'll just 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:

bash script.sh

Another tip is that you can put this at the top of the file:

#!/usr/bin/env bash

and then make sure its an executable:

chmod +x script.sh

and voila, you can run it as a regular script:

./script.sh

Resources:

Like this post? Consider buying me a coffee to support me writing more.

Want to receive quarterly emails with new posts? Signup for my newsletter

Did you find this article valuable?

Support Alec Brunelle by becoming a sponsor. Any amount is appreciated!

ย