Linux Applications

How to Install Fish Shell on Linux

In this guide, we will demonstrate how to install the Fish shell on various Linux systems.

Prerequisites:

To perform the demonstrated steps in this guide, you need the following components:

Shells in Linux

In UNIX/Linux, a shell acts as an interface between the user and the underlying system. It takes the user input, parses the command, and calls the necessary programs with given parameters. Whenever we work with CLI, we’re actually interacting with the shell.

There are various shell applications available for any Linux system:

    • The original shell program which is “sh”.
    • An enhanced version of sh which is “Bash”.
    • Other third-party shell programs; for example – Fish, zsh, csh, etc.

The Fish Shell

Fish (friendly and interactive shell), as the name suggests, aims to be a user-friendly command-line shell for the supported platforms (Linux, macOS, BSD, and Windows). It’s an open-source project that comes with a handful of interesting features:

    • Auto suggestion
    • Tab completion
    • Syntax highlighting
    • Designed to work out-of-the-box without any extensive configuration
    • Fish scripting language

Note that the Fish scripting language isn’t compatible with any other shell.

Installing Fish on Linux

The Fish shell is officially available for all the major Linux distros (Debian, Ubuntu, Fedora, CentOS, openSUSE, and more). For advanced users, Fish can also be compiled and installed from the source code.

At the time of writing this guide, the latest version of Fish is v3.6.1.

Ubuntu

The default Ubuntu repo contains the following Fish shell:

$ apt info fish

 

However, it’s an older release. To get the latest Fish shell, we have to add the following Fish repo:

$ sudo add-apt-repository ppa:fish-shell/release-3

 

$ sudo apt update && sudo apt install fish

 

Debian

The Fish shell is available from the following default Debian repo:

$ apt info fish

 

However, the latest release of Fish is only available from the backports repo. On Debian 11 Bullseye, the following command configures the backports repo:

$ echo "deb http://deb.debian.org/debian bullseye-backports main contrib non-free" | sudo tee -a /etc/apt/sources.list.d/backports.list

 

Then, update the APT cache.

$ apt update

 

By default, the backports repo is disabled to preserve the stability and compatibility. The following command temporarily overrides this restriction and installs the Fish shell from the backports repo:

 $ apt install fish/bullseye-backports

 

Arch Linux

The latest version of the Fish shell is directly available from the default repo. Use pacman to install the Fish shell:

$ sudo pacman -S fish

 

openSUSE

There are dedicated Fish shell repos for both openSUSE Leap and Tumbleweed.

To configure the repo on openSUSE Tumbleweed, run the following commands:

$ sudo zypper addrepo https://download.opensuse.org/repositories/shells:fish:release:3/openSUSE_Tumbleweed/
shells:fish:release:3.repo

 

$ sudo zypper refresh

 
To configure the repo on openSUSE Leap 15.4, run the following commands:

$ sudo zypper addrepo https://download.opensuse.org/repositories/shells:fish:release:3/15.4/
shells:fish:release:3.repo

 

$ sudo zypper refresh

 

Finally, install the Fish shell:

$ sudo zypper install fish

 

Fedora

The latest version of the Fish shell is directly available from the default package repo. Run the following command to install Fish:

$ sudo dnf install fish

 
Gentoo Linux

To install Fish on Gentoo, run the following command:

$ emerge fish

 
Void Linux

Fish shell is also available on Void Linux:

$ xbps-install fish-shell

 

Installing Fish from the Source

The complete instruction of building Fish from source is available on GitHub. In this section, we will demonstrate how to build and install Fish on Ubuntu.

Prerequisite Packages

We need to install the following packages to properly build and install Fish:

$ sudo apt install build-essential cmake ncurses-dev libncurses5-dev libpcre2-dev gettext

 

Grabbing the Source Code

Download the source tarball:

$ wget https://github.com/fish-shell/fish-shell/releases/download/3.6.1/fish-3.6.1.tar.xz

 

Extract the tarball:

$ tar -xvf fish-3.6.1.tar.xz

 

Building Fish

Now, we can start compiling the source code:

$ cd fish-3.6.1/

 

$ mkdir build && cd build

 

$ cmake ..

 

$ make -j$(nproc)

 

 

Installing Fish

Once the binary is compiled, the following command installs Fish in /usr/local:

$ sudo make install

 

Using Fish

The official documentation on Fish shell can be found here. This section demonstrates a handful of them.

To launch the Fish shell, run the following command:

$ fish

 

Syntax Highlighting

If a valid command is entered, the syntax is highlighted normally:

$ echo hello world

 

If an invalid command is entered, Fish highlights it red:

$ invalid_command

 

Valid File Paths

When typing a file path, it is underlined if the file path is valid:

$ cat ~/.bashrc

 

$ cat /non/existent/path

 

Built-In Themes

The Fish shell comes with a handful of themes by default. To list all the available themes, run the following command:

$ fish_config theme show

 

To apply a different theme, run the following command:

$ fish_config theme choose <theme_name>

 

To disable the syntax highlighting altogether, use the following command instead:

$ fish_config theme choose None

 

Conclusion

We demonstrated how to install the Fish shell on various Linux distros. We also showcased how to build and install Fish from the source. Finally, we demonstrated some basic usage of the Fish shell.

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.