Bash and Zsh
Bash has been around for a very long time (since 1989) and if you open up a Terminal on Linux or Mac, you’ve seen Bash since it has been the shell of choice for a very long time. You can run commands, create aliases for commands, define and export variables, make functions and that’s about it.
Zsh is not much different from Bash, in fact it is an extended version of Bourne Shell (the same shell that Bash is based on) with plenty of new features, and support for plugins and themes. One of the coolest things about Zsh is color customization. You can easily change the theme and color of your shell just by using a framework called Oh My Zsh.
But both Bash and Zsh are limited in many ways. They both lack modern features like tab completions and autosuggestion, and can be a bit harder to configure if you are a beginner.
Why you should use Fish instead
Fish is the most user-friendly command line shell in my opinion. It has a number of smart features and improvements when compared to other shells, namely Bash and Zsh. When you first start typing in Fish, you will immediately notice that it has an autosuggestion feature where, as you type, Fish will suggest commands to you based on your shell history. Also as you are typing you will notice the commands will change color. When the command is not complete it will be red meaning it is not a valid command and once it is valid it will turn blue. For example when you type c
it will be in red because it is not a command, but when you add a d
to run cd
it will turn blue because cd
is a valid command. Also Fish supports 24 bit true color and it is customizable so you can make it look however you want.
Tab completions in Fish are really quite amazing. You don't need to add any plugins or hack Fish in any weird way to get tab completion to work either, unlike with Bash or Zsh. As you type a command, hit TAB
and you will be presented a list of possible commands. If you are unsure of a flag for a command, you can hit TAB
while typing flags, and you will get a list of possible flags. So if you type ls -
and then hit TAB
, you will get the flags for ls
. Fish gets this data from the man-pages installed on your machine.
Configuring the Fish shell
Fish is configurable although for most users the default configuration will do the job very well. But for those that love to hack on things, Fish can be configured easily without ever needing to edit the config files manually. There is a built-in web configuration tool that you can launch with fish_config
. This will open a page in your browser where you select the features and themes that you want. When you're done you just save the configuration and voila! Another easy way to configure Fish is with the Oh My Fish framework. Oh My Fish provides an infrastructure to allow you to install packages that extend or modify the look of Fish. It's easy to install with just one command in the terminal, and it's easy to use.
Scripting in the Fish shell
Fish is fully scriptable. Its syntax is simple, clean and consistent. It has a sane syntax where things like if
and case
statements no longer have to be closed with fi
and esac
, you can just use end
. While the difference in syntax from Bash can be discouraging for some, it is really easy to get the hang of it and feels more natural. You can also define universal variables, which are shared instantaneously with all running Fish sessions and persists through shell restarts.
Cons of using Fish shell
Nothing is perfect so Fish has its down sides as well. First it is not compatible with POSIX sh. Depending on how you look at it this can be a positive and a negative thing. This just means that it's a separate language (like Java, Python) rather than an implementation or extension of sh (like Bash, Dash). Some other features are missing like no support for !!
, but you can use the Oh My Fish framework and install the bang-bang
plugin to have this shortcut in the fish Shell.
Conclusion
Depending on your needs you might be satisfied with Bash or Zsh but even when doing basic tasks the Fish shell can be a lot more helpful than the others. I certainly recommend trying Fish if you haven't already. You will be amazed by all of its advanced features that just work without the need to spend multiple hours on configuration.
Top comments (1)
I have this comparison, BASH, FISH and Ion Shell.
BASH
This require IFS.
🕷️ epsi.bitbucket.io/lambda/2021/02/0...
FISH
This require two functions
🕷️ epsi.bitbucket.io/lambda/2021/02/0...
and
Ion Shell
Still alpha.
🕷️ epsi.bitbucket.io/lambda/2021/02/1...