Getting Comfortable With The Fish Shell

by Ostatic Staff - Jun. 12, 2013

Fish is the Friendly, Interactive SHell, a shell that takes a modern look at the command line. Fish includes syntax highlighting, tab completion, and auto-suggestions by default, making your time in the terminal faster and more efficient. But beyond those features, which are available in other shells, Fish is a philosophy on application development and design. Fish is a command line interface built to be easy to use.

It is an unfortunate truth that many people equate text-based interfaces with a steep learning curve. Unfortunate, and ironic while the same people are searching Google and expecting instant search results. Typing arcane commands into a shell can be intimidating at first, but after even a brief period of training a moderately skilled computer user can become competent on the command line. The design of the interface determines usability, not the chosen medium. Although the medium provides certain affordances, Fish shows that even the archaic command line can be modernized through opinionated design.

To really understand the Fish shell, I recommend reading the design document. Once you understand the philosophy of the shell, exploring some of the nice features Fish provides becomes much more fun. Some productivity enhancing tools can be a bit of a chore to learn, even if they do speed up your workflow, not so with Fish. I have so far thoroughly enjoyed digging into this shell and remapping some of the muscle memory in my fingers to accommodate niceties like auto-suggestions based on previous commands.

The design document is worth reading in its entirety, but here are a few highlights:

Configurability is the root of all evil

Every configuration option in a program is a place where the program is too stupid to figure out for itself what the user really wants, and should be considered a failure of both the program and the programmer who implemented it.

And:

The law of discoverability

A program should be designed to make its features as easy as possible to discover for the user.

While the open source community often prides itself on the infinite configurability of our tools, an unfortunate side effect is that too many options can be paralyzing. Both of these quotes could come straight out of a Human-Computer Interaction textbook, and it is refreshing to see the principles of HCI applied to the command line.

Configuring the Fish shell is very different from standard .profile or .bashrc files. You can configure Fish through a web interface, or directly on the command line. For example, today I created a new function I call “all_serv”, which simply reads a text file list of server names and SSH’s to each of them, executing an optional command. To create the function, I entered the following:

     function all_serv
for each in (cat /home/jon/etc/servers)

ssh $each $argv

end
end

Then, to save the function for use in future shells, I enter funcsave all_serv, and the shell saves this function for future use. Different, but nice all the same.

Sysadmins and developers can get attached to a specific shell, like an old pair of jeans or a comfortable coat. The Fish shell is an invitation to try something new, and I’ve found that it is well worth the temporary awkwardness. The shell feels good once you try it on, I imagine it will wear well over time.