Fish

From ArchWiki
Revision as of 10:43, 12 July 2013 by Flu (Talk | contribs)

Jump to: navigation, search

Fish is a user friendly commandline shell intended mostly for interactive use.

Installation instructions

Install fish from the official repositories.

To verify that it has been installed you can run:

$ grep fish /etc/shells

If you wanted to make Fish your default shell run:

$ chsh -s /usr/bin/fish

Configuration

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 ~/.config/fish/config.fish:

# 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
        set last_status $status
        set_color $fish_color_cwd
        printf '%s' (prompt_pwd)
        set_color normal
        printf '%s ' (__fish_git_prompt)
       set_color normal
end

If su starts with Bash (because Bash is the default shell), define a function in Fish:

$  funced su
function su
        /bin/su --shell=/usr/bin/fish $argv
end
$ funcsave su

Pacman and Fish

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.

Troubleshooting

In Arch, there are a lot of shell scripts written for Bash, and these have not been translated to Fish. It is advisable not to set Fish as your default shell because of this. The best 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 don't support setting the shell it would look like this:

SHELL=/usr/bin/fish lilyterm

Another option is to 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. This is contrast to changing the default shell for the user which would cause the above mentioned problem.

To set Fish as the shell started in tmux, put this into your ~/.tmux.conf:

set-option -g default-shell "/usr/bin/fish"

Not setting Fish as system wide default allows the arch scripts to run on startup, ensure the environment variables are set correctly, and generally reduces the issues associated with using a non-Bash compatible terminal like Fish.

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 .profile or .bash_profile as it is only executed for login shells.

if status --is-login
        set PATH $PATH /usr/bin /sbin
end

Note that you will need to manually add various other environment variables, such as $MOZ_PLUGIN_PATH. It is a huge amount of work to get a seamless experience with Fish as your default shell.

Current state of Fish development

The original developer, Axel Liljencrantz has abandoned the project. The rest of his team slowly took over and transferred the codebase to gitorius.

So far several bug fixes are available from the git repository. Also, there is an AUR package for the git master branch, which is considered stable for everyday use: fish-gitAUR.

On May 30, 2012 ridiculous_fish has announced a new fork of Fish which has been adopted as mainstream later, and development is now relocated to github. The AUR package fish-shell-gitAUR follows the head branch of that, while the Fish package in the official repositories provides latest stable milestones as announced on the webpage.

Ridiculous_fish has announced fish 2.0 stable version at May 17th, 2013.

See also