The Friendly Interactive Shell, or fish, is" friendly" because its easier to use, not because its" dumbed down."
The past two columns introduced two fairly new and nontraditional shells: zoidberg and vshnu. The former is written in Perl and accepts Perl code on the command-line, while the latter is is very visual, allowing you to navigate and manipulate the file system with one or two keystrokes at a time. Both avoid the hassle of learning yet another syntax.
Indeed, if you’ve felt frustrated by the syntax of a traditional shell, you’re in the same boat as the author of the Friendly Interactive Shell, or fish, used to be — until he decided to write fish, that is. Axel Liljencrantz explains his beefs about POSIX-type shell syntax in his overview of fish in LWN.net, online at http://lwn.net/Articles/136232/. His design document, which makes thought-proviking reading for shell gurus, is at http://roo.no-ip.org/fish/user_doc/design.html.
Most readers of this column are comfortable with traditional shells, so shells that are “user-friendly” (meaning simple or limited) may not seem very useful. Still, the traditional interface has lots of room for surprisingly-useful extensions and changes to make the shell more consistent and simpler. So a “friendly” shell like fish can be worth a look. (And, as we’ll see, fish really isn’t that limited.)
For example. the syntax highlighting in fish is a great way to avoid errors like misspelled command names, invalid options, and unmatched quotes. Moreover, Tab-completion — for commands, options, and more — is more complete than in many shells, and you may find quoting in fish easier to understand than other shells’ implementations.
Finally, because fish was designed from scratch, the interface is more consistent, and its semantics are more like a normal programming language. For instance, variables have scope, and setting and managing variables and arrays is simpler. fish also doesn’t use subprocesses to isolate difficult-to-handle jobs like command substitution, so you don’t have to remember the strange ways that a subprocess interferes with the shell’s state.
After you’ve installed fish — from one of the packages or from source at http://roo.no-ip.org/fish/ — you can start it by typing fish at the prompt from another shell. To go back to your original shell, just type exit. Later, after you test your installation, you might decide to make fish your default shell. (Shell-switching works both ways, of course: if fish is your default shell, you can drop into the Z Shell temporarily by typing zsh at a fish prompt.)
Many shells have Tab-key completion for command names, filenames, and more. Fish does, too, but its Tab completion stands out because it includes a description of each file’s contents and each option, because it can complete wildcard and curly-brace expressions, and because its completion of cd takes CDPATH into account.
In Listing One, the first command-line is rm and a space. Because rm takes a filename argument, pressing Tab at this point lists the four entries in this directory and describes each one. In the second command-line, man what followed by a Tab lists the man pages that begin with what.