Article

Table of Contents
Try Vultr Today with

$50 Free on Us!

Installing Fish Shell on Ubuntu

Published on: Mon, Aug 24, 2015 at 12:19 pm EST
Server Apps Ubuntu

All servers deployed on Vultr are configured to use the Bash shell by default. Fish is an alternative for Bash that provides the following additional features:

  • Command suggestion.
  • A more intuitive command system.
  • An overall more modern shell.

This tutorial will teach you how to install Fish on Ubuntu Server.

Installation

Step 1: Downloading Fish

You can install Fish with apt-get:

apt-get install fish

Step 2: Entering Fish

You can now enter the Fish shell simply by typing:

fish

Step 3: Setting Fish as your default shell

You can set Fish as your default shell instead of Bash:

chsh -s /usr/bin/fish

This way, Fish will be used automatically every time you log in. Test this setting by exiting SSH, then logging back in. Upon logging in, you will be presented with a Fish shell.

Step 4: Creating a config file

In order to be able to change the properties of the Fish shell, we first need to create a config file.

mkdir -p ~/.config/fish
vim ~/.config/fish/config.fish

Step 5: Removing the default message

By default, Fish will show this message when you enter the shell:

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

You can remove this message by adding the following to the ~/.config/fish/config.fish file:

set -g -x fish_greeting ''

This will remove the message and rather set it to a blank value. You can add something such as "Welcome to my server!" by entering a value instead of leaving it blank:

set -g -x fish_greeting 'Welcome to my server!'

Step 6: Switching back to Bash

If you would like to use Bash again, simply type:

bash

If you want to permanently use Bash as your default shell, type:

chsh -s /bin/bash

Using Fish

Fish will suggest file names and commands while you’re typing. For example, say that you have a file called test.txt in your home directory. You would only have to type vim ~/te and Fish will complete that to ~/test.txt for you.

Exporting variables isn’t done with the export command. Fish uses the set command. To export a variable, given that the variable name is Var and the value is Val, you’d execute: set -x Var Val. If you would like to see the value of Var, type: env | grep Var. This will return the value like this:

Var=Val

In order to remove (erase) a variable, given that the name of the variable you want to erase is Var, you can type set -e Var. You will notice that running env | grep Var now produces an empty output list.

If you would like to learn more about the usage of Fish, please refer to the official documentation.

Want to contribute ?

You could earn up to $300 by adding new articles