Fish shell


Command line interfaces, CLIs, are great.

The first I used was BASIC on the Amstrad CPC 464, in glorious yellow on blue.

Then I used DOS. It had disks. Disks were good.

When I finally learned to Linux—I was a little late to the party, it was already 2001—I of course discovered bash, the “bourne again shell”. It was a fun part of a whole new world.

I don’t actually remember how I first encountered fish, the “friendly interactive shell”, but when I did I totally fell in love with it.

Why’s that, I hear you ask. Let me start by quoting fish’s own web page.

Finally, a command line shell for the 90s.

And I can only agree: it has features you will very soon be mystified you ever lived without.

Suggest as you type

You know how when you type in your browser’s address bar, or while coding, it helpfully suggests things you might mean?

And how it’s incredibly helpful and never gets in the way?

Fish does that.

Underline paths as you type

As you type a command, fish underlines the argument you’re currently typing if it’s a prefix of a valid path; and once you press space it underlines arguments that are complete valid paths.

So for example if there are files abc and def in the current directory and you start typing

cat ab

then ab is underlined to show that it’s a path or a path prefix; and you can press “tab” to complete it.

If you go on to type

cat abc def ghi

then before you hit return you can see that it’s going to have trouble, because abc and def are underlined and okay but ghi is not underlined, so it’s not a valid path and that’s going to be an error.

Suggestions based on files

Because fish has already noticed when you issue any command which arguments were paths, it records this in the history.

Then if you type something like that again, it will only eagerly suggest the same command again if the files you are mentioning still exist.

Which very often means it magically suggests exactly what you are aiming for.

Simple goodness

I won’t try to give an exhaustive list of fish’s features, but rather, here is what it feels like: it feels like every detail has been carefully considered and optimized for smooth and fast usage.

Here’s a really small example. You’ve probably used a UI for manipulating files in which clicking or double-clicking a folder opens the folder. That makes sense because “open” is exactly the right default action for a folder you’re not currently in. Now in the CLI world, what do most shells do when you just mention a folder?

$ ./subdirectory
bash: ./subdirectory: Is a directory

Yes, I know! What do you think I want to do with it?

Fish knows.

Compatibility

Fish scripts aren’t 100% compatible with any other shell, and I realize that might be a concern.

It turns out to not be a problem for me. You can of course run bash script files from fish and fish script files from bash without any problems, so if you’re writing actual script files you can just choose as you like. For “one liners” fish is easy to pick up, it mostly guides you interactively through the differences from other shells. And, you can easily mix in another shell interactively, for example using bash -c to run a single command or bash to drop temporarily into a bash shell.

Where to get it

🔗 Fish shell



📄 Tools
📄 Fish shell