Install and use Fish shell in Linux

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

Fish Shell stands for friendly interactive shell which is fully-equipped, smart and user-friendly command-line shell that supports a lot of handy features unlike any other shell.

Features are Autosuggestion, Sane Scripting, Man Page Completions, Web-Based configuration and Glorious VGA Color.

Fish shell makes your command line more productive, useful & fun without remembering a bunch of Linux commands because of their handy features.

let’s go ahead and install it by following the below steps.

Installing Fish shell in Linux

Fish shell canbe installed easily since it is available in the default repositories of most Linux distributions. In case, if it is not available in your distro, please add Fish shell official repository to install it.

$ sudo yum install fish
$ sudo dnf install fish
$ sudo apt install fish
[root@unixcop ~]# yum install fish -y
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:18:47 ago on Sun Aug  1 15:24:38 2021.
Dependencies resolved.
======================================================================================================================================================
 Package                                    Architecture                  Version                              Repository                        Size
======================================================================================================================================================
Installing:
 fish                                       x86_64                        3.1.2-2.el8                          epel                             3.0 M
Installing dependencies:
 libpkgconf                                 x86_64                        1.4.2-1.el8                          baseos                            35 k
 pcre2-utf32                                x86_64                        10.32-2.el8                          baseos                           220 k
 pkgconf                                    x86_64                        1.4.2-1.el8                          baseos                            38 k
 pkgconf-m4                                 noarch                        1.4.2-1.el8                          baseos                            17 k
 pkgconf-pkg-config                         x86_64                        1.4.2-1.el8                          baseos                            15 k
Installing weak dependencies:
 man-pages                                  x86_64                        4.15-6.el8                           baseos                           5.9 M
 man-pages-overrides                        noarch                        8.3.0.2-2.el8                        appstream                         70 k

Transaction Summary
======================================================================================================================================================
Install  8 Packages

Total download size: 9.3 M
Installed size: 20 M
Downloading Packages:
(1/8): libpkgconf-1.4.2-1.el8.x86_64.rpm                                                                               50 kB/s |  35 kB     00:00    
(2/8): pcre2-utf32-10.32-2.el8.x86_64.rpm                                                                             233 kB/s | 220 kB     00:00    
(3/8): pkgconf-1.4.2-1.el8.x86_64.rpm                                                                                 125 kB/s |  38 kB     00:00    
(4/8): man-pages-overrides-8.3.0.2-2.el8.noarch.rpm                                                                    36 kB/s |  70 kB     00:01    
(5/8): pkgconf-m4-1.4.2-1.el8.noarch.rpm                                                                               78 kB/s |  17 kB     00:00    
(6/8): pkgconf-pkg-config-1.4.2-1.el8.x86_64.rpm                                                                       24 kB/s |  15 kB     00:00    
(7/8): man-pages-4.15-6.el8.x86_64.rpm                                                                                438 kB/s | 5.9 MB     00:13    
(8/8): fish-3.1.2-2.el8.x86_64.rpm                                                                                    210 kB/s | 3.0 MB     00:14    
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                 497 kB/s | 9.3 MB     00:19     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                              1/1 
  Installing       : pkgconf-m4-1.4.2-1.el8.noarch                                                                                                1/8 
  Installing       : pcre2-utf32-10.32-2.el8.x86_64                                                                                               2/8 
  Installing       : libpkgconf-1.4.2-1.el8.x86_64                                                                                                3/8 
  Installing       : pkgconf-1.4.2-1.el8.x86_64                                                                                                   4/8 
  Installing       : pkgconf-pkg-config-1.4.2-1.el8.x86_64                                                                                        5/8 
  Installing       : man-pages-overrides-8.3.0.2-2.el8.noarch                                                                                     6/8 
  Installing       : man-pages-4.15-6.el8.x86_64                                                                                                  7/8 
  Installing       : fish-3.1.2-2.el8.x86_64                                                                                                      8/8 
  Running scriptlet: fish-3.1.2-2.el8.x86_64                                                                                                      8/8 
  Verifying        : man-pages-overrides-8.3.0.2-2.el8.noarch                                                                                     1/8 
  Verifying        : libpkgconf-1.4.2-1.el8.x86_64                                                                                                2/8 
  Verifying        : man-pages-4.15-6.el8.x86_64                                                                                                  3/8 
  Verifying        : pcre2-utf32-10.32-2.el8.x86_64                                                                                               4/8 
  Verifying        : pkgconf-1.4.2-1.el8.x86_64                                                                                                   5/8 
  Verifying        : pkgconf-m4-1.4.2-1.el8.noarch                                                                                                6/8 
  Verifying        : pkgconf-pkg-config-1.4.2-1.el8.x86_64                                                                                        7/8 
  Verifying        : fish-3.1.2-2.el8.x86_64                                                                                                      8/8 

Installed:
  fish-3.1.2-2.el8.x86_64            libpkgconf-1.4.2-1.el8.x86_64     man-pages-4.15-6.el8.x86_64       man-pages-overrides-8.3.0.2-2.el8.noarch    
  pcre2-utf32-10.32-2.el8.x86_64     pkgconf-1.4.2-1.el8.x86_64        pkgconf-m4-1.4.2-1.el8.noarch     pkgconf-pkg-config-1.4.2-1.el8.x86_64       

Complete!
[root@unixcop ~]# 

So For Arch Linux based systems, use pacman command to install fish shell.

$ sudo pacman -S fish

Installing Fish shell using Official repository

For Ubuntu and their derivatives, use apt command to install fish shell.

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

Fedora, use DNF command to install fish shell.

$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_31/shells:fish:release:3.repo
$ sudo dnf install fish

For Debian

$ sudo wget -nv https://download.opensuse.org/repositories/shells:fish:release:3/Debian_10/Release.key -O Release.key
$ sudo apt-key add - < Release.key $ sudo echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_10/ /' > /etc/apt/sources.list.d/shells:fish:release:3.list
$ sudo apt-get update
$ sudo apt-get install fish

For RHEL/CentOS systems, use YUM command to install fish shell.

On RHEL 8:

$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/RHEL_8/shells:fish:release:3.repo
$ sudo yum install fish

On CentOS 8:

$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/CentOS_8/shells:fish:release:3.repo
$ sudo dnf install fish

For CentOS 7:

$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo
$ sudo yum install fish

For openSUSE Leap system, use zypper command to install fish shell.

$ sudo zypper addrepo https://download.opensuse.org/repositories/shells:/fish:/release:/3/openSUSE_Leap_15.2/shells:fish:release:3.repo
$ suod zypper refresh
$ sudo zypper install fish

Fish shell Usage

Once the fish shell installed successfully, just type fish in your terminal, which will automatically switch to the fish shell from the default bash shell.

$ fish

Below screenshot shows that the Fish shell is ready to use. “fish” default prompts the username, hostname, and working directory which canbe even customized, based on your requirement by executing the fish_prompt function.

Auto Suggestion

When you type few letters of commands in the fish shell, it will auto suggest a command in a light grey color which were recently used.

Tab Completion

After typing the desired command, press Tab button to discover any relevant commands.

Refer screenshot below:

Press the Tab button one more time to see the full list.

Also for example , you can move to the next directory with tab button to excute the command cd on this directory as shown above.

Syntax highlighting

Fish performs syntax highlighting, while typing any commands in the terminal.Invalid commands willbe highlighted in RED color.

Fish Shell will appear the valid with blue color wherein the invalid paths will appear in Red color

Web based configuration

Fish shell has a cool feature, that allow us to set colors, prompt, functions, variables, history and bindings via web browser.

Run the following command in the terminal, to launch the Web configuration interface.

Once executed, press Ctrl+c to exit .

root@unixcop ~# fish_config
Web config started at file:///tmp/web_configvim9bkn0.html
Hit ENTER to stop.

Conclusion

Tutorial has been precisely prepared to discuss about various features of Fish Shell.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook