How To Install Fish, A Smart Command Line Shell for Gnu/Linux/Hurd and *BSD.

How To Install Fish, A Smart Command Line Shell for Gnu/Linux/Hurd and *BSD

Miguel Menéndez

Fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.

If you want to make your command line more productive, more useful, and more fun, without learning a bunch of arcane syntax and configuration options, then fish might be just what you’re looking for!

Why would someone use fish instead of another shell?

  • Autosuggestions. fish suggests commands as you type based on history and completions, just like a web browser.
  • Sane Scripting. fish is fully scriptable, and its syntax is simple, clean, and consistent. You will never write esac again.
  • Man Page Completions. Other shells support programmable completions, but only fish generates them automatically by parsing your installed man pages.
  • Glorious VGA Color. fish natively supports term256, the state of the art in terminal technology. You will have an astonishing 256 colors available for use!
  • Web Based configuration. For those lucky few with a graphical computer, you can set your colors and view functions, variables, and history all from a web page.
  • Works Out Of The Box. fish will delight you with features like tab completions and syntax highlighting that just work, with nothing new to learn or configure.

With these instructions you can install the fish shell on

It also provides a basic configuration and how to get back to bash shell (temporarily or permanently).

Installing fish on Debian or another ‘.deb’ distribution

For Ubuntu and its forks, there is a PPA repository (See it below).

Add the repository and download and install the repository key to apt:

~$ su -

For Debian 8

~# echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_8.0/ /' >> /etc/apt/sources.list.d/fish.list
~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Debian_8.0/Release.key
~# apt-key add - < Release.key</pre>

For Debian 7

~# echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_7.0/ /' >> /etc/apt/sources.list.d/fish.list
~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Debian_7.0/Release.key
~# apt-key add - < Release.key

For Debian 6

~# echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_6.0/ /' >> /etc/apt/sources.list.d/fish.list
~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Debian_6.0/Release.key
~# apt-key add - < Release.key

Update and upgrade the system:

~# apt-get update
~# apt-get upgrade

Install fish:

~# apt-get install fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ su -c 'chsh -s /usr/bin/fish user-name'

Installing fish on Ubuntu and its forks

Add the PPT repository to apt:

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

Update and upgrade the system:

~$ sudo apt-get update
~$ sudo apt-get upgrade

Install fish:

~$ sudo apt-get install fish

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ sudo chsh -s /usr/bin/fish user-name

Installing fish on Fedora

Add the repository to yum:

~$ su -
~# cd /etc/yum.repos.d/

For Fedora 23

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Fedora_23/shells:fish:release:2.repo

For Fedora 22

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Fedora_22/shells:fish:release:2.repo

For Fedora 21

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Fedora_21/shells:fish:release:2.repo

For Fedora 20

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Fedora_20/shells:fish:release:2.repo

For Fedora 19

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Fedora_19/shells:fish:release:2.repo

For Fedora 18

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/Fedora_18/shells:fish:release:2.repo

Update and upgrade the system:

~# yum repolist
~# yum update

Install fish:

~# yum install fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ su -c 'chsh -s /usr/bin/fish user-name'
If $ su - does not work, try $ sudo -i. If $ su -c 'command' does not work, try $ sudo command.

Installing fish on CentOS

Add the repository to yum:

~$ sudo -i
~# cd /etc/yum.repos.d/

For CentOS 7

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo

For CentOS 6

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo

For CentOS 5

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_5/shells:fish:release:2.repo

Update and upgrade the system:

~# yum repolist
~# yum update

Install fish:

~# yum install fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ sudo chsh -s /usr/bin/fish user-name
If $ sudo -i does not work, try $ su -. If $ sudo command does not work, try $ su -c 'command'.

Installing fish on RedHat

Add the repository to yum:

~$ sudo -i
~# cd /etc/yum.repos.d/

For RedHat 7

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/RHEL_7/shells:fish:release:2.repo

For RedHat 6

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/RedHat_RHEL-6/shells:fish:release:2.repo

For RedHat 5

~# wget http://download.opensuse.org/repositories/shells:fish:release:2/RedHat_RHEL-5/shells:fish:release:2.repo

Update and upgrade the system:

~# yum repolist
~# yum update

Install fish:

~# yum install fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ sudo chsh -s /usr/bin/fish user-name
If $ sudo -i does not work, try $ su -. If $ sudo command does not work, try $ su -c 'command'.

Installing fish on openSUSE

Install using One Click Install:

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ sudo chsh -s /usr/bin/fish user-name
If $ sudo -i does not work, try $ su -. If $ sudo command does not work, try $ su -c 'command'.

Installing fish on Arch, Manjaro and another ‘AUR distribution’

Update and upgrade the system:

~$ su -
~# pacman -Syu

Install fish:

~# pacman -S fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ su -c 'chsh -s /usr/bin/fish user-name'
If $ su - does not work, try $ sudo -i. If $ su -c 'command' does not work, try $ sudo command.

Installing fish on Gentoo

Update and upgrade the system:

~$ su -
~# emerge --sync
~# emerge --update @world

Install fish:

~# emerge app-shells/fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ su -c 'chsh -s /usr/bin/fish user-name'
If $ su - does not work, try $ sudo -i. If $ su -c 'command' does not work, try $ sudo command.

Installing fish on FreeBSD

Update and upgrade the system:

~$ su -
~# freebsd-update fetch
~# freebsd-update install

Install fish:

~# pkg install shells/fish
~# exit

Make fish your default shell:

~$ chsh -s /usr/bin/fish

If you want to make fish the default shell of another user:

~$ su -c 'chsh -s /usr/bin/fish user-name'

Basic configuration (Optional)

The fish shell is now installed and fully functional, but a bit more configuration will prove helpful.

Create the fish config directory (May already have been created):

~$ mkdir -p ~/.config/fish

Create a config file:

~$ nano ~/.config/fish/config.fish

Add this line to add /usr/local/bin to the PATH environment variable:

if status --is-login
  set PATH $PATH /usr/bin /usr/sbin /usr/local/bin /bin /sbin
end

Open a new terminal, which should now load the fish shell for the first time:

A new terminal with fish shell.

You can type help (followed by the Enter key) to load user documentation in your default web browser:

Fish user documentation loaded in your default web browser.
To stop the http server: Enter

You can see your current configuration in your default browser by typing the command fish_config:

Current fish configuration loaded in your default web browser.
To stop the http server: Enter

Fish can parse your installed man pages and automatically generate completion files for your command line tools. You should periodically run the fish_update_completions command to update those completions which, by default, is stored in ~/.local/share/fish/generated_completions/.

Finally, if you want to eliminate the fish welcome message that appears by default:

A new terminal with fish shell with the default welcome message.

Run the following command:

~$ echo "set -g -x fish_greeting ''" >> ~/.config/fish/config.fish
A new terminal with fish shell without the default welcome message.

If you want to add your own custom welcome message instead of removing the message entirely, insert your preferred text inside the '' marks:

~$ echo "set -g -x fish_greeting 'Hello World!'" >> ~/.config/fish/config.fish
A new terminal with fish shell with a personal welcome message.

Getting back to bash

If you want to temporarily switch to the bash shell for a single session, run:

~$ bash
Type exit to return to your fish shell.

If you want to permanently revert your default shell back to bash:

~$ chsh -s /bin/bash

To make bash the default shell of another user:

~$ su -c 'chsh -s /bin/bash user-name'
If $ su -c 'command' does not work, try $ sudo command.

Comments

Found a bug? Do you think something could be improved? Feel free to let me know and I will be happy to take a look.