If you are searching for some alternatives to Z Shell (zsh), then you should stop searching anymore because you have found the right article where you will learn how to install fish (friendly interactive shell) on your Linux machine.
In our previous posts, we already discussed that bash is not the only shell to use in a Linux system, and for this reason, we have come up with the zsh shell, but on the internet, the fish shell is highly appreciated for its simplicity.
When I say simplicity, then I mean it because when you install the fish shell on your system, most of the basic functionality of the shell takes place automatically, like tab completion, which is one of the prime features of this shell. Not only that, but you will also find syntax highlighting, which will alert you that you are typing the wrong program name in the “red” color. If it’s a valid program, then the colour will turn blue.
Moreover, you can use some of the built-in commands and keybindings which take the fish shells to different levels in terms of flexibility, like my favourite options for navigating around previous and next directories using prevd and nextd, or I can use the shortcut Alt + Left arrow and Alt + Right arrow for the same.
You can expect a lot more features from the fish shell without doing much customization. So let me show you how to install fish on all major Linux distributions with Starship.
Install Fish on major Linux distributions
Installation of fish is as easy as installing any application on a Linux distribution. You just need to follow the below steps in a given order as per your respective distributions.
Install fish on Ubuntu and Debian-based distributions
Ubuntu-based users need to run the following command to install the fish shell on Ubuntu-based distributions like Linux Mint, Pop!_OS, and Feren OS.
$ sudo apt-add-repository ppa:fish-shell/release-3
$ sudo apt update
$ sudo apt install fish
Debian 11 users need to run the following command to install fish shell:
$ sudo echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_11/ /' | sudo tee /etc/apt/sources.list.d/shells:fish:release:3.list
$ sudo curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_11/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish_release_3.gpg > /dev/null
$ sudo apt update
$ sudo apt install fish
Install fish on CentOS, AlamaLinux, Fedora, and any other RHEL-based distributions
You can easily install a fish shell on the RedHat-based system by simply executing the following command and the only catch is that you just need to make sure that you are throwing the right command as per your installed distributions.
CentOS 8: users need to run the following command to install fish shell:
$ sudo cd /etc/yum.repos.d/
$ sudo yum install fish
Fedora 36: users need to run the following command to install fish shell:
$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:3/Fedora_36/shells:fish:release:3.repo
$ sudo dnf install fish
AlmaLinux or RockyLinux: users need to run the following command to install fish shell:
$ sudo dnf update
$ sudo dnf install fish
openSUSE Tumbleweed: users need to run the following command to install fish shell:
$ sudo zypper addrepo https://download.opensuse.org/repositories/shells:fish:release:3/openSUSE_Tumbleweed/shells:fish:release:3.repo
$ sudo zypper install fish
Install fish on Arch Linux
In Garuda Linux, you will find the fish shell, but in other arch-based distros like Manjaro Linux, Arch Linux, RebornOS, and others, you need to run the following command to install the fish shell.
$ sudo pacman -Su
$ sudo pacman -Sy fish
Install fish using Homebrew
Well, many users also prefer to install packages using the Homebrew package manager. If you are also one of them, then execute the following command:
$ brew install fish
I have tried to show installation steps for all major Linux distributions for the latest version. If you are not finding the installation steps for your current version of your distribution, then check out this page.
Change your current shell to a fish shell
Once the installation is complete, you can run fish, but it will get closed as soon as you close your current shell. Therefore, to make the changes persist, you need to change your current shell.
But how do I change the current shell to fish?
It is simple. First, open your terminal screen and run the following command, which will show you all the shells that are available to use on your system along with their path.
$ cat /etc/shells
Below is the output of the above command.
Once you know the path where the fish is installed, run another command which will replace the current shell with the fish shell.
$ chsh -s /bin/fish
$ chsh -s $(which fish)
As you run the above command, it will prompt for your password, so simply put it in, and after that, you will get the gentle message on the screen which will show “Shell changed.”
Yes, shell has been changed successfully according to the above response, but you can also verify the changes from the /etc/passwd file, which stores information about the login shell.
To check that, run the below command.
$ grep 'fish' /etc/passwd
If the “fish” is attached to your username, then the changes have been implemented successfully. Now you just need to restart the system to reflect the new changes.
After restart, you will find the bash shell has been replaced by a fish shell with a welcome message on top: “Welcome to fish, the friendly interactive shell.” Type help for instructions on how to use ” fish” like the below-attached image.
Configure fish for Basic usage
You can skip this section if you want to install Starship over the fish shell, which is also a better alternative way to configure the fish shell according to your preference, but over here we will introduce some of the basic configurations of the fish shell without adding any extra layer of software.
Supress or disable greeting message in fish shell
One of the annoying things you may find is greeting messages, which you will find every time whenever you open the terminal screen, so to suppress them you can add one line of statement to
~/.config/fish/config.fish which we will see now.
First, open the above-mentioned file using any command line editor.
$ nano ~/.config/fish/config.fish
After that, add the below-mentioned line to it and open another terminal window to see the changes.
Below is the output of the above command after suppressing the greeting message.
Start Web UI to configure fish
Apart from disabling greeting messages, you can also configure your terminal colours, prompt design, and set custom aliases. Apart from that, you can also view the command history which you passed on your terminal and keybinding to manage fish shell in a pro manner.
All this can be configured from the Web UI, which you can access very easily by executing the below command.
Once you invoke the above command, it will take you to your default browser where you will find the above-mentioned option like in the below-attached image.
In this article, it’s not possible for me to take you through all the available options, but if you want, I’ll make a different article on this topic.
If anyone is interested, then drop a comment below.
Install and Configure Starship
One of the popular shell prompts for the fish shell is Starship, which you can install very easily on a Linux machine. To install Starship you just need to have a curl utility to download and start the installation process by executing the below command:
$ curl -sS https://starship.rs/install.sh | sh
Once you invoke the command, you will be prompted for the location and password like in the below image, so simply accept the default path and enter the password.
After completion of the above command, add the following line to ~/.config/fish/config.fish by running the below command:
$ echo "starship init fish | source" >> ~/.config/fish/config.fish
And once you are done with the changes, open a new terminal window to reflect new changes.
You have finally installed Starship on the fish shell.
Before ending this article, I would like to show you how you can install some of the preset themes on Starship, which will make your terminal stand out from other Linux users.
There are six presets available to use from this I have selected Bracketed Segments for this article. If you want to install the same, then execute the below code in your terminal window and start another terminal to reflect the changes.
$ starship preset bracketed-segments > ~/.config/starship.toml
The behaviour of the above command:
That’s all for now!
Well in this article you have learned how to install fish shell on major Linux distributions apart from the installation, you have also got the idea of how to configure fish shells according to your preference.
Later on, we also had Starship to add the cherry on the cake.
If you like this article or want to suggest some useful tips for new fish users, then do let us know. It would be highly appreciated.
To learn more about fish you can follow this Tutorial.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.