Interactive use¶
fish prides itself on being really nice to use interactively. That’s down to a few features we’ll explain in the next few sections.
fish is used by giving commands in the fish language, see The fish Language for information on that.
Help¶
fish has an extensive help system. Use the help command to obtain help on a specific subject or command. For instance, writing help syntax displays the syntax section of this documentation.
fish also has man pages for its commands, and translates the help pages to man pages. For example, man set will show the documentation for set as a man page.
Help on a specific builtin can also be obtained with the -h parameter. For instance, to obtain help on the fg builtin, either type fg -h or help fg.
The main page can be viewed via help index (or just help) or man fish-doc. The tutorial can be viewed with help tutorial or man fish-tutorial.
Autosuggestions¶
fish suggests commands as you type, based on command history, completions, and valid file paths. As you type commands, you will see a suggestion offered after the cursor, in a muted gray color (which can be changed with the fish_color_autosuggestion variable).
To accept the autosuggestion (replacing the command line contents), press right (→) or ctrl-f. To accept the first suggested word, press alt-right (→) or alt-f. If the autosuggestion is not what you want, ignore it: it won’t execute unless you accept it.
Autosuggestions are a powerful way to quickly summon frequently entered commands, by typing the first few characters. They are also an efficient technique for navigating through directory hierarchies.
If you don’t like autosuggestions, you can disable them by setting $fish_autosuggestion_enabled to 0:
set -g fish_autosuggestion_enabled 0
Tab Completion¶
Tab completion is a time saving feature of any modern shell. When you type tab, fish tries to guess the rest of the word under the cursor. If it finds exactly one possibility, it inserts it. If it finds more, it inserts the longest unambiguous part and then opens a menu (the “pager”) that you can navigate to find what you’re looking for.
The pager can be navigated with the arrow keys, pageup / pagedown, tab or shift-tab. Pressing ctrl-s (the pager-toggle-search binding - / in vi mode) opens up a search menu that you can use to filter the list.
fish provides some general purpose completions, like for commands, variable names, usernames or files.
It also provides a large number of program specific scripted completions. Most of these completions are simple options like the -l option for ls, but a lot are more advanced. For example:
manandwhatisshow the installed manual pages as completions.makeuses targets in the Makefile in the current directory as completions.mountuses mount points specified in fstab as completions.apt,rpmandyumshow installed or installable packages
You can also write your own completions or install some you got from someone else. For that, see Writing your own completions.
Completion scripts are loaded on demand, like functions are. The difference is the $fish_complete_path list is used instead of $fish_function_path. Typically you can drop new completions in ~/.config/fish/completions/<name-of-command>.fish and fish will find them automatically.
Syntax highlighting¶
fish interprets the command line as it is typed and uses syntax highlighting to provide feedback. The most important feedback is the detection of potential errors. By default, errors are marked red.
Detected errors include:
Non-existing commands.
Reading from or appending to a non-existing file.
Incorrect use of output redirects
Mismatched parenthesis
To customize the syntax highlighting, you can set the environment variables listed in the Variables for changing highlighting colors section.
fish also provides pre-made color themes you can pick with fish_config.
Running just fish_config opens a browser interface, or you can use fish_config theme from fish:
# disable nearly all coloring
fish_config theme choose none
# restore fish's default theme
fish_config theme choose default
Or, to see all themes, right in your terminal:
fish_config theme show
To update the theme of all shell sessions without restarting them, first have those sessions define an event handler by adding the following to your config.fish and restarting them:
function apply-my-theme --on-variable=my_theme
fish_config theme choose $my_theme
end
Then, set the corresponding universal variable from any session:
> set -U my_theme lava
> set -U my_theme snow-day
Syntax highlighting variables¶
The colors used by fish for syntax highlighting can be configured by changing the values of various variables. The value of these variables can be one of the colors accepted by the set_color command.
Options accepted by set_color like
--foreground=,
--background=,
--bold,
--dim,
--italics,
--reverse,
--strikethrough,
--underline and
--underline-color=
are also accepted.
Example: to make errors highlighted and red, use:
set fish_color_error red --bold
The following variables are available to change the highlighting colors in fish:
Variable |
Meaning |
|---|---|
|
default color |
|
commands like echo |
|
builtin commands like cd and set - this falls back on the command color if unset |
|
user-defined functions - this falls back on the command color if unset |
|
keywords like if - this falls back on the command color if unset |
|
quoted text like |
|
IO redirections like >/dev/null |
|
process separators like |
|
syntax errors |
|
