fish
and other shells.fish
, like many other shells, performs tab completion, i.e. the shell tries to guess what the user is typing and complete the users sentences whenever the user presses the tab key. If the shell finds more than one possible completion, a list of all completions is displayed when the users double taps on tab. fish
extends tab completion functionality in several ways:
fish
performs file completion on strings containing wildcardsfish
adds a description to each completion. For files this description is a description of the format or filetype, like 'C source code', 'Character device' or 'Executable'. For variables, if the value is short enough, the variable value will be displayed. For commands, if there is room and few enough commands, the whatis description of the command is used.fish
has extensive command specific completions, including completion of specific options. This is very powerful in combination with completion descriptions, as the user can see what each option does without consulting the manual. Simply type the command you wish to use, type a dash and double tab TAB, and the screen will fill with a list of the commands options and a description of what they do.fish
uses a decent pager when the results won't fit on one screen. The pager can scroll up and down, both one row and one page at a time, and if any non movement key is pressed the pager exits without consuming the character. Therefore, there is no need to press 'q' to exit before typing your completion.
Some examples of the completions performed by fish
fish
supports using the X-Windows clipboard for storing copy and paste information. This feature is automatically enabled if the DISPLAY environment variable is set. For more information on how to use copy and paste in fish
, read this section. This means you can easily share commands and strings between different shell sessions and applications.open *.html
and all the HTML files in your current directory will be opened in your default browser. No longer will you have to convert your filenames to URLS, remember clunky Open Office command names, worry about absolute paths or any the other common pitfalls when opening files from the commandline.fish
is heavily commented. Both the source code and the program in general features a great deal of easily accessible documentation. The help
command is used to display HTML-based help files. Just type help
and a subject, and the help system will try to fill your needs. To view the page you are reading right now, you could simply type help difference
. help
also works great together with tab completion. Write help
and double tap on tab, a list of all help sections will be displayed, with a description of the content of each section.Also, all builtin commands have a help option. Passing '-h' or '--help' to any builtin will give you the same help as the help command, but formated for output on screen.
fish
performs syntax highlighting of commands as they're entered. Pretty colors may look nice (or awful, depending on your taste), but the real advantage is error flagging. The syntax highlighting function does extensive error cheching and will flag many common errors such as misspelling a command or option, or reading from a non-existent file.
fish
also highlights matching quotes and parenthesis as the cursor moves over them. This is very useful when typing long, complex commands.
fish
knows it's terminal. fish
uses the terminfo database to get more information on the current terminal. Some of the terminal handling features of fish
are:
fish
thanks to the use of terminfo. If you've been bitten by this, you'll know what this means.fish
was in the foreground, this is detected and the command line is redrawn.
fish
uses wide character strings internally, including double width characters, so it should be ready for all your Unicode needs.
fish
features an intelligent history that automatically removes any duplicate items. Searching is performed by entering a search string and using the up/down arrow keys to go to the next/previous match. On exit, fish
performs a merge between the history on file and the history in memory history, thus making sure that multiple copies of fish
running concurrently will not erase each others history information.fish
has a simple syntax. There is only one form of alias/function/whatever, accessed through the function
builtin. The are very few builtins, fish
relies on normal commands like echo
, kill
, printf
and time
instead of reimplementing them as builtins.
The globbing in fish is significantly simplified. Since I can never remember all the subtle differences between single and double quotes, which kind of tick is used for subshells and all the other strange quirks of subshells, that aspect of shells has been significantly simplified. This makes fish
unsuitable for strange shell scripting, but much more suited to interactive needs than regular shells.
There is no difference between double and single quotes. They both turn of all globbing and escape sequences. They can be nested.
Token separation is performed before variable expansion. This means that even if a variable contains spaces, it will never be separated into multiple arguments. If you want to tokenize a string, you can use the tokenize command.
Subshells are specified using parenthesis.
There is no math mode, us bc.
The POSIX way of setting variables is lame. Whitespace sensitive languages are awful. "foo=bar" and "foo = bar" should not mean different things? fish
uses a builtin, set
to set and remove environment variables. This keeps things consistent. In fish, everything, including the switch/case statement is a command.
In fish
, all block types are ended by the end
command.