How I changed my shell to fish

Yasuhiro
4 min readMay 2, 2022

Hi, thank you for reading. In this post, let’s see how to change your shell to fish shell, and how to make your terminal look like the capture above.😊

I’ve used zsh for 2 years and had nothing to complain about, but I changed it to fish shell because it has useful features like

  • syntax highlighting
  • faster than zsh
  • colorful text
  • auto-suggestion

They are all built-in and easy to start. And my coding environment got way better than it was before. That’s why I wrote this article, and want more people to use fish shell. 👍

Before moving on, I have to say that I write codes every day but don’t write shell code much. So if you are a programmer enthusiast for shell code, you have another post to read.

I changed not only shell but also the appearance of my terminal(iTerm2, Terminal), so I wrote for 2 sections: first, installing fish shell with a couple of useful plugins, and second, configuring the terminal appearance.

1. fish shell installation and recommended plugins.

Installation(This is managed by brew)

brew install fish

Go to https://fishshell.com/ for another way of installation.

Set-Up

To store configuration write it to a file called ~/.config/fish/config.fish.

.fish scripts in ~/.config/fish/conf.d/ are also automatically executed before config.fish.

Use fish as a login shell

These two lines of code will do.

# Add 'fish' to /etc/shells
echo $(which fish) | sudo tee -a /etc/shells
# Execute in fish shell
chsh -s $(which fish)

That’s all for start using fish! So easy!

Now you can use fish as a default shell.

Remove Intro message.

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

If you don’t like this message above showing up on each start, type it to suppress it.

touch ~/.config/fish/functions/fish_greeting.fish

Here are the plugins you should add

  • Fisher

fish plugin manager

# installation
curl -sL <https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish> | source && fisher install jorgebucaran/fisher
# for install plugin
fisher install <plugin name>
  • Z

Jump to the directory where you want to go based on the frequency of your visit by command z.

# install using fisher
fisher install jethrokuan/z

You can check detailed usage below.

Next, we make the appearance of terminals much cooler!

2. Customize the appearance

Let’s install 1 app and 2 font packages.

Powerline (This is managed by pip)

Installation

pip install powerline-status

Then add this function to config.fish

set fish_function_path $fish_function_path "{repository_root}/powerline/bindings/fish" powerline-setup

You can find a repository_root by pip show powerline-status and replace {repository_root}for it.

After this installation, your terminal may be garbled characters, but don’t worry we will fix this later.

Powerline fonts

This is the font set.

Installation

# clone 
git clone <https://github.com/powerline/fonts.git> --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

https://github.com/powerline/fonts#quick-installation

Nerd Fonts

Installation

using brew

brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font

but it didn’t work for me. so I used curl command instead.

cd ~/Library/Fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" <https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf>

Installed fonts are located on~/Library/Fonts .

 
# -> Droid Sans Mono for Powerline Nerd Font Complete.otf SFMono-Regular.otf
...

Apply these fonts to terminals

For iTerm2.

iTerm2 -> Preferences -> Profiles -> Text

you can select each font for ASCII and Non-ASCII.

  1. In ASCII selection, you can choose whatever font you like.
  2. In Non-ASCII selection, choose ‘Droid Sans Mono for Powerline Nerd Font Complete’ Fonts to avoid garbled characters.

💡 Tips: Both fonts need to be the same size to look nice on the terminal. (I set 18.)

Here’s my setting.

My settings of fonts on iTerm2

For Terminal

Terminal -> Preferences

Unlike iTerm2, you can set only 1 font.

So choose ‘Droid Sans Mono for Powerline Nerd Font Complete’.

My settings of fonts on Terminal

Now you have a nice-looking terminal!

Any comments and improvements are welcomed.

Thank you for reading 👍

--

--