- 1 Installation
- 2 Configuration
- 3 Troubleshooting
- 4 Tips and tricks
- 4.1 Not setting fish as default shell
- 4.2 Setting fish as default shell
- 4.3 Disable greeting
- 4.4 Make su launch fish
- 4.5 Start X at login
- 4.6 Use liquidprompt
- 4.7 Put git status in prompt
- 4.8 Evaluate ssh-agent
- 4.9 The "command not found" hook
- 4.10 Remove a process from the list of jobs
- 4.11 Quickly set a persistent alias
- 5 See also
Install the package. Alternatively install the AUR package for the development version.
Once installed simply type
fish to drop into the fish shell.
Documentation can be found by typing
help from fish; it will be opened in a web browser. It is recommended to read at least the "Syntax overview" section, since fish's syntax is different from many other shells.
User configurations for fish are located at
~/.config/fish/config.fish. Adding commands or functions to the file will execute/define them when opening a terminal, similar to
The fish prompt and terminal colors can be set with the interactive web interface:
Selected settings are written to your personal configuration file. You can also view defined functions and your history.
fish can generate autocompletions from man pages. Completions are written to
~/.config/fish/generated_completions/ and can be generated by calling:
You can also define your own completions in
/usr/share/fish/completions/ for a few examples.
Context-aware completions for Arch Linux-specific commands like pacman, pacman-key, makepkg, cower, pbget, pacmatic are built into fish, since the policy of the fish development is to include all the existent completions in the upstream tarball. The memory management is clever enough to avoid any negative impact on resources.
Fish does not implement history substitution (e.g.
sudo !!), and the fish developers have said that they do not plan to. Still, this is an essential piece of many users' workflow. Reddit user, crossroads1112, created a function that regains some of the functionality of history substitution and with another syntax. The function is on github and instructions are included as comments in it. There is a forked version that is closer to the original syntax and allows for
command !! if you specify the command in the helper function.
Other alternatives to regaining the
command !! syntax can be found on Fish' github wiki. The examples here include e.g. the
bind_bang function which expands
!! to the latest command in the history (this will of course make it impossible to do to bangs in a row as they will expand). Another option is the command given on this github issue.
Tips and tricks
Not setting fish as default shell
In Arch, some shell scripts are written for Bash and are not fully compatible with fish. Not setting fish as system wide or user default allows the Bash scripts to run on startup, ensures the environment variables are set correctly, and generally reduces the issues associated with using a non-Bash compatible terminal like fish. You may see some script errors if your default shell is set as fish. Below are several options for using fish without setting it as your default shell.
Modify .bashrc to drop into fish
Keep your default shell as Bash and simply add the line
exec fish to the appropriate Bash#Configuration files, such as
.bashrc. This will allow Bash to properly source
/etc/profile and all files in
/etc/profile.d. Because fish replaces the Bash process, exiting fish will also exit the terminal. Compared to the following options, this is the most universal solution, since it works both on a local machine and on a SSH server.
- In this setup, use
bash --norcto manually enter Bash without executing the commands from
~/.bashrcwhich would run
exec fishand drop back into fish.
- To color the hostname in the prompt differently in SSH mode, here in bright red, one can use the line
if [ -n "$SSH_TTY" ]; then exec fish -C 'set -g fish_color_host brred'; else exec fish; fiin the Bash configuration file instead of simply
Some entities stop working, e.g. scp to server with this setup will not work.
Use terminal emulator options
Another option is to open your terminal emulator with a command line option that executes fish. For most terminals this is the
-e switch, so for example, to open gnome-terminal using fish, change your shortcut to use:
gnome-terminal -e fish
With LilyTerm and other light terminal emulators that do not support setting the shell it would look like this:
You can also set fish as the default shell for the terminal in the terminal's configuration or for a terminal profile if your terminal emulator has a profiles feature.
Whenever you open your terminal emulator, you will be dropped into fish.
Use terminal multiplexer options
To set fish as the shell started in tmux, put this into your
set-option -g default-shell "/usr/bin/fish"
Whenever you run tmux, you will be dropped into fish.
Setting fish as default shell
If you decide to set fish as your default shell, you may find that you no longer have very much in your path.
You can add a section to your
~/.config/fish/config.fish file that will set your path correctly on login. This is much like
.bash_profile as it is only executed for login shells.
if status --is-login set PATH $PATH /usr/bin /sbin end
$MOZ_PLUGIN_PATH. It is a huge amount of work to get a seamless experience with fish as your default shell using this method. A better idea would be #Not setting fish as default shell.
By default, fish prints a greeting message at startup. To disable it, run
set -U fish_greeting once.
Make su launch fish
If su starts with Bash (because Bash is the default shell), define a function in your fish configuration file:
function su /bin/su --shell=/usr/bin/fish $argv end
Start X at login
Add the following to the bottom of your
# Start X at login if status --is-login if test -z "$DISPLAY" -a $XDG_VTNR = 1 exec startx -- -keeptty end end
Put git status in prompt
If you would like fish to display the branch and dirty status when you are in a git directory, you can add the following to your
# fish git prompt set __fish_git_prompt_showdirtystate 'yes' set __fish_git_prompt_showstashstate 'yes' set __fish_git_prompt_showupstream 'yes' set __fish_git_prompt_color_branch yellow # Status Chars set __fish_git_prompt_char_dirtystate '⚡ ' set __fish_git_prompt_char_stagedstate '→ ' set __fish_git_prompt_char_stashstate '↩ ' set __fish_git_prompt_char_upstream_ahead '↑ ' set __fish_git_prompt_char_upstream_behind '↓ ' function fish_prompt printf '%s@%s %s%s%s%s> ' (whoami) (hostname) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (__fish_git_prompt) end
More explanations about the parameters can be found in the fish-shell git.
eval (ssh-agent) generate errors due to how variables are set. To work around this, use the csh-style option
$ eval (ssh-agent -c)
The "command not found" hook
pkgfile includes a "command not found" hook that will automatically search the official repositories, when entering an unrecognized command. This hook will be run by default if is installed.
Remove a process from the list of jobs
fish terminates any jobs put into the background when fish terminates. To keep a job running after fish terminates, first use the
disown builtin. For example, the following starts
firefox in the background and then disowns it:
$ firefox & $ disown
This means firefox will not be closed when the fish process is closed. Seein fish for more details.
Quickly set a persistent alias
To quickly make a persistent alias, one can simply open up fish shell and use the following method:
$ alias FooAliasName "foo" $ funcsave FooAliasName
This will set you alias as a persistent fish shell function. if you wish to see all functions and/or edit them, one can simply use
fish_config to view or edit all functions under the Function tab in the resulting web configuration page.