fish

From Gentoo Wiki
Jump to: navigation, search

Resources

fish - the friendly interactive shell.

fish is a smart and user-friendly command line shell for OS X, Linux, and the rest of the family. fish includes features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.

Installation

Emerge

Install app-shells/fish:

root #emerge --ask app-shells/fish

Caveats

Fish is not a POSIX 1003.1 compatible shell. It does not read /etc/profile, /etc/profile.env, or the /etc/profile.d/* directories.

It is advised not to set fish as a default login shell. see bug #545830 for more details.

Some packages install files into /etc/profile.d and are not compatible with fish. Not setting fish as system wide or user default allows the standard shell 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. Those who really, truly, actually wish to set the fish shell can jump down to Setting the fish shell as the login shell. For all other readers, it is best to proceed down the .bashrc safety net path.

.bashrc safety net

The following is a trick suggested by one of the fish developers and the Arch wiki. This enables the fish shell to inherit the bash environment (which written in and should be executed by the bash shell):

FILE ~/.bashrc
if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi


# Put your fun stuff here.



# keep this line at the bottom of ~/.bashrc
[ -x /bin/fish ] && SHELL=/bin/fish exec /bin/fish

Please note it should not be run for non-interactive shells, so make sure it's placed below the test for interactive shell.

Launch bash using:

user $bash --rcfile /etc/profile

bass

An utility called bass which executes a given command in bash and then transfers updated environment variables back into fish. With bass, one can then make fish load the system-wide environment variables simply by adding following line to their ~/.config/fish/config.fish file:

FILE ~/.config/fish/config.fish
bass source /etc/profile

Setting the fish shell as the login shell

Those who really wish make fish their default login shell can change the shell:

user $chsh -s /bin/fish
Warning
After setting fish as the login shell there probably will be entries missing in the PATH variable and some packages that rely on /etc/profile.d broken.

Configuration

fish starts by executing commands in ~/.config/fish/config.fish . You can create it if it does not exist. Since the version 2.0 it is possible to configure fish within a web browser session by running:

user $fish_config

Fish can generate completions from man pages. To generate completions run:

user $fish_update_completions

External resources