How To Install And Configure Fish Shell In Ubuntu 20.04 LTS?


In Unix-like operating systems such as Linux, a shell is a program that interprets the command, executes, takes input(s), and prints output(s) on a terminal window. A shell acts as an intermediary between user and kernel. It is available to use when you launch the terminal window. Bash (bourne again shell ) comes default with many Linux distributions.

Like other shells such as zsh, ksh, or bash, fish is a smart and user-friendly shell. In this article, we will discuss to install and configure the fish shell in Ubuntu 20.04 LTS.

Types of shells used in Unix?

Majorly Unix shells can be categorized into two type –

  1. Bourne Shell (sh) – It has $ character as default prompt. POSIX shell (sh), bash, Korn shell, etc are the shells that come under this category.
  2. C Shell (csh) – It uses % character as default prompt.  Z shell, c shell, tcsh are some shells that come under this category.

Fish shell

The friendly interactive shell also abbreviated as fish, is a smart and user-friendly Unix shell. Its syntax derives neither from the bourne shell and nor from the c shell, So it is considered as an exotic shell. Unlike many other shells that disable many features by default to save system resources, it enables many of them to provide more features to its users. Some of its features are given below –

Features of fish shell

  • It provides auto-suggestions based on previous commands executed.
  • You can configure it through the web
  • Provide advanced tab completion feature
  • Syntax highlighting with strict error checking
  • Supports for X clipboard
  • It maintains searchable command history

How to install fish shell

The fish shell can be easily installed through the terminal. First, update the apt’s source list by using –

sudo apt update

And then use the following command to install fish shell in Ubuntu 20.04 LTS –

sudo apt install fish

Now it could prompt you to install a few additional packages such as fish-common, Press y, and then enter to proceed with download and installation process.

How to use fish shell

Once the installation of the fish shell gets completed. You can start using it by executing the following command in your terminal.

fish

When you type a command in the terminal, based on previously run commands it automatically suggests the complete command in light grey color for example when I press s it suggests me command as given in the image below –

For using the tab completion feature first write a few words and then press the tab button to see the possible commands that can be used.

The fish shell highlights invalid commands by turning it into the red color while valid commands are displayed in a different color. Similarly, a valid path gets underlined while invalid paths turn its color into red. You can see the syntax highlighting in the following image-

Configuring fish shell

To configure shell write fish_config on command prompt and press enter. This will open the configuration settings in your default web browser. Here you can choose the color, set a new prompt, can see the history of commands executed. The fish configuration menu is given below-

You can exit from the fish shell to bash by executing exit command in the terminal.

How to set fish as your default shell

When you access the fish shell using fish command it gives you temporary access to the shell. When you reopen your terminal you will be back to the default shell again.

To make fish the default shell first you need to locate it –

whereis fish

Then execute the following command –

chsh -s /usr/bin/fish

If prompt you to enter the password then enter it. Now fish is set as your default shell.

To set bash as your default shell again, use-

$ chsh -s /bin/bash

Ok, that’s all for now. If you have something to say then write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.