Fish Shell Introduction
As a developer you spend a lot of time in the terminal so it’s important to be happy and as productive as possible whilst you’re in there.
This is why I’m a big fan of the Fish Shell in particular. The Fish Shell is a user friendly shell with really handy features like auto-suggestions and tab completions that come preconfigured, no need to install additional plugins and mess around with config files. That’s not to say Fish Shell isn’t configurable, there are plugins available.
If you prefer to watch how this is done then skip all the way to the end for a video detailing the process. 🚀
Ok, let’s look at a typical navigation example in bash, if you want to
change directory, you have to enter
cd followed by the directory
name. In Fish you only need to type out the directory name.
Similarly if you want to go back a directory in bash, you need to
cd in Fish it’s just a case of
1# change directories in bash2cd Downloads3cd ../4# change directories in fish5Downloads/6../
Fish will suggest both directories and commands as you type away, you will see suggestions in grey which you can tab onto to select.
If you want to go through you last
npm) commands, rather
than (like in bash) arrow through all you previously entered commands
(I know you can use
Ctr+r in bash) or print out the history and look
In Fish if you start typing out your command, let’s say
yarn you can
then arrow through all commands that have included
yarn it doesn’t
even have to be the beginning of the command, if you have used a
package and want to know what else you installed with it at the time
you can use the package name then arrow though all command with that
keyword in there.
Aliases are where you’re too lazy to keep typing in the full command
again and again so you make a shorter one, for me I have aliased
g in Fish, (I know, but that extra two characters over time is a
Aliases in shells like bash and zsh you need to open your config file and find a appropriate place to add you alias. In
To make aliases in Fish shell use:
1alias yga 'yarn global add'2# remember to save it3funcsave yga
Abbreviations are like having text expander in your terminal, so much
like with the aliases I can shorten
g the difference with
abbreviations is that hitting the spacebar after that will expant it
out to git.
1# add yarn global add2abbr -a yga 'yarn global add'3# type yga then space, result is 👇4yarn global add
Ok, time to go over an install, this is specifically for Windows Subsystem Linux (WSL) but is the same instructions if you’re on Linux:
1sudo apt -y install fish
Depending on what version of Ubuntu you’re on you may need to add the v3 package which consists of adding a PPA:
1# check your fish version2fish -v3# if the version isn't v3 add the PPA 👇4sudo apt-add-repository ppa:fish-shell/release-35sudo apt update && sudo apt install fish -y6fish -v7# fish, version 3.1.2 👍
As a side note, I use fish on my work hardware so for macOS using brew it’s:
1brew install fish2curl -L https://get.oh-my.fish | fish3sudo bash -c 'echo /usr/local/bin/fish >> /etc/shells'4chsh -s /usr/local/bin/fish
At this point I’m still in bash and can change to Fish by entering
fish in bash to switch to it.
If I want to default to Fish each time I can use the
1# if you want to default to fish shell2# use this command in bash3chsh -s $(which fish)4# use this command in fish5chsh -s (which fish)
One thing about using WSL is that it always starts the shell in the users folder on the C drive, I’ll change this by defaulting the start location to a folder of my choosing.
1# create a repos folder in my home folder2mkdir ~/repos3# edit the fish config4nano ~/.config/fish/config.fish5# add the starting directory in there6cd ~/repos
Oh My Fish is touted as the Fishshell Framework but all I have used
it for is the extensive themes available, once you have installed OMF
you can list them out in the terminal with:
There’s previews available on the OMF Themes Markdown doc.
To install OMF:
1curl -L https://get.oh-my.fish | fish
There’s a few things I’ll install with
1omf install spacefish nvm
As I’ll need to have node installed I’ll be using nvm to manage my node versions:
1curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Because I installed the nvm package with fish there’s no need to worry about adding the variables output from the nvm insall, I can install my required node version:
1nvm install 14
Lastly there are projects I work on that use Yarn so I’ll need to install that too, in this case it’s the instructions from the Yarn site.
1curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -2echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list3sudo apt update && sudo apt install yarn -y
That’s it, I’ve detailed some of the advantages of using the Fish shell and detailed getting set up from a fresh install.
Back to Top