A better tool
Nowadays accepted default for a POSIX shell is bash. A piece of software from 1989, but made compatible with Bourne shell, which is from 1977. That’s a lot of time and even more so in the realm of software. Even couple years can bring a drastic change to the tools we are using but here we are stuck with something from almost 40 years ago.
Of course, there’s nothing critically bad about bash or it would be replaced a long time ago. But given all the advances in the computers in the last decades, it’s possible that we could do better. At least in the realm of user interaction, which is something which changed the most throughout all those years.
That’s where fish shell comes. An attempt to modernize shell by breaking with the POSIX compatibility. And it does quite a good job at that.
Biggest selling point
What convinced me, at first, is still my favorite feature: out of the box autosuggestion. They are blazingly fast which means I can recall the previous command with the minimal effort. Plus it works across a wide spectrum of things. From files through command history up to command line options.
Of course, bash has it too, but it’s hidden behind shortcuts and configuration options. On the contrary in fish, it kicks in as soon as you start typing. If you like what it found then you can invoke special shortcut (ctrl+f) to select it. If not you just type what you were intending to and fish will not interfere. This workflow fits me nicely in my brain and it’s something I don’t plan to give up.
Rarely I have only one shell open. They tend to multiply. Usually, by the end of the day, I may have a dozen or so with various commands or little things to try to them.
If I want to change any of the shell configuration I can just do it in one and the change will be immediately be reflected in all other copies. It’s all powered by global shell variables and it saves from having to manually close each one of the shells and open it again with to reflect the new config.
Shell for programmers
Anyone I know will readily admit that bash is bad as a programming language. Due to backwards compatibility, there’s a lot of weird corner cases which makes it harder than it should be. One example is setting a variable. Why I can’t put spaces around
=? (I actually got curious and I dig out the reason: it’s because the first shell was using a macro preprocessor and that relied on this exact form. That restriction was carried forward since.)
Fish was designed from the ground up as a programming language. It means there are not corner cases or obscure syntax for achieving what you want. As an example of simplicity consider that there’s no need to remember to end
end everywhere which is so liberating. It almost makes programming shell fun.
Bye bye copy & paste
Not everything is so rosy. The price for all those amazing features is breaking up with POSIX compatibility.
In reality, it means that no code on the Internet will work as it is. It requires some translation. Usually, it’s not that difficult. In most cases search & replace fixes the problem.
The most annoying thing is when some application assumes POSIX shell and runs a command in a terminal. Sudden beeping means the command needs to be adjusted by hand and re-run again.
It’s not that big of a deal but it gets tedious.
One line is not always enough
Fish changes the way in which shell variables are handled. Instead of overloading
= it uses special
set statement. It’s great when inspecting a piece of code because there any variable is immediately obvious.
On the other hand, it makes it impossible to set an environment variable just for one command. For example the following bit of bash:
$ NODE_PATH=./lib node server.js
needs to be translated into two lines in fish:
$ set -x NODE_PATH ./lib $ node server.js
With more environment variables it quickly can grow out of hand.
I get that the name of fish is really Friendly Interactive Shell and I get the nice play on the sea theme. The name even alludes that it’s superior to the traditional shells because fishes can move where shells are stuck to the one place.
Yet in the era of Google having a common word as an application name is a terrible idea. Finding anything regarding fish shell requires a puzzle to be solved: what other keywords will make the search query be associated with a piece of software and not with marine life. Sometimes it brings some interesting bits about the underwater world, so maybe, in the end, this is a feature?
The breaking off from the tradition and backward compatibility on one hand brings improved user interface, matching modern software. On the other it makes it bit more difficult to take advantage of existing shell programming knowledge. Each person needs to decide if the improvements are worth the pain of using a non-standard tool.