How To Install Fish, The Friendly Interactive Shell, In Linux
======
Fish, acronym of friendly interactive shell, is a well equipped, smart and user-friendly shell for Unix-like systems. Fish comes with many significant features, such as autosuggestions, syntax highlighting, searchable history (like CTRL+r in Bash), smart search functionality, glorious VGA color support, web based configuration, man page completions and many, out of the box. Just install it and start using it in no time. No more extra configuration or you don’t have to install any extra add-ons/plug-ins!
In this tutorial, let us discuss how to install and use fish shell in Linux.
#### Install Fish
Even though fish is very user-friendly and feature-rich shell, it is not included in the default repositories of most Linux distributions. It is available in the official repositories of only few Linux distributions such as Arch Linux, Gentoo, NixOS, and Ubuntu etc. However, installing fish is not a big deal.
On Arch Linux and its derivatives, run the following command to install it.
You can find the default fish configuration at ~/.config/fish/config.fish (similar to .bashrc). If it doesn’t exist, just create it.
#### Auto suggestions
When I type a command, it automatically suggests a command in a light grey color. So, I had to type a first few letters of a Linux and hit tab key to complete the command.
If there are more possibilities, it will list them. You can select the listed commands from the list by using up/down arrow keys. After choosing the command you want to run, just hit the right arrow key and press ENTER to run it.
No more CTRL+r! As you already know, we do reverse search by pressing ctrl+r to search for commands from history in Bash shell. But it is not necessary in fish shell. Since it has autosuggestions capability, just type first few letters of a command, and pick the command from the list that you already executed, from the history. Cool, yeah?
#### Smart search
We can also do smart search to find a specific command, file or directory. For example, I type the substring of a command, then hit the down arrow key to enter into smart search and again type a letter to pick the required command from the list.
You will notice the syntax highlighting as you type a command. See the difference in below screenshots when I type the same command in Bash and fish shells.
As you see, “sudo” has been highlighted in fish shell. Also, it will display the invalid commands in red color by default.
#### Web based configuration
This is yet another cool feature of fish shell. We can can set our colors, change fish prompt, and view functions, variables, history, key bindings all from a web page.
To start the web configuration interface, just type:
Bash and other shells supports programmable completions, but only fish generates them automatically by parsing your installed man pages.
To do so, run:
```
fish_update_completions
```
Sample output would be:
```
Parsing man pages and writing completions to /home/sk/.local/share/fish/generated_completions/
3435 / 3435 : zramctl.8.gz
```
#### Disable greetings
By default, fish greets you (Welcome to fish, the friendly interactive shell) at startup. If you don’t this greeting message, you can disable it. To do so, edit fish configuration file:
```
vi ~/.config/fish/config.fish
```
Add the following line:
```
set -g -x fish_greeting ''
```
Instead of disabling fish greeting, you can also set any custom greeting message.
```
set -g -x fish_greeting 'Welcome to OSTechNix'
```
#### Getting help
This one is another impressive feature that caught my attention. To open fish documentation page in your default web browser from Terminal, just type:
```
help
```
The official documentation will be opened in your default browser. Also, you can use man pages to display the help section of any command.
```
man fish
```
#### Set Fish as default shell
Liked it very much? Great! Just set it as default shell. To do so, use chsh command:
```
chsh -s /usr/bin/fish
```
Here, /usr/bin/fish is the path to the fish shell. If you don’t know the correct path, the following command will help you.
```
which fish
```
Log out and log in back to use the new default shell.
Please remember that many shell scripts written for Bash may not fully compatible with fish.
To switch back to Bash, just run:
```
bash
```
If you want Bash as your default shell permanently, run:
```
chsh -s /bin/bash
```
And, that’s all for now folks. At this stage, you might get a basic idea about fish shell usage. If you’re looking for a Bash alternatives, fish might be a good option.