Tuan-Anh Tran
May 17, 2020

From Zsh to Fish on macOS

Posted on May 17, 2020  •  2 minutes  • 300 words

I recently give fish shell another try and it doesn’t disappoint me this time.

The support from various tools has improve tremendously and the ecosystem seesm to be a lot more mature last I tried.

It tooks me like 15-20 minutes to migrate over everything to fish and it seems fish provides everything I need from zsh out of the box. Remind me why I need oh-my-zsh again?

Installation

Install via homebrew and set fish as default shell.

brew install fish
chsh -s (which fish)

To go back to zsh: do chsh -s (which zsh).

Migration

fish’s configuration is located at $HOME/.config/fish. The equivalent of .zshrc or .bashrc is config.fish at $HOME/.config/fish.

Sourcing

The source command work just like normal. By default, fish will source from files in $HOME/.config/fish/conf.d folder automatically so you can put your aliases, functions, .. there.

Fixing functions

A typical function in fish looks like this. I take gi (gitignore) function as a simple example. Seems pretty straightforward and even more self-explain than in zsh.

function gi -d "gitignore.io cli for fish"
	set -l params (echo $argv|tr ' ' ',')
	curl -s https://www.gitignore.io/api/$params
end

Checking other stuff you use

If there’s no fish support from the tool you use, there’s bass which add support for bash utilties from fish shell.

Example with nvm:

bass source ~/.nvm/nvm.sh --no-use ';' nvm use node # latest

However, using bass can make it quite slow in some cases. So if the tools you use do support fish, use it native functions.

Package manager

There are:

I haven’t actually check them all out. I just went with the first result I got (fisher) and it’s working pretty well for the purpose.

Disable welcome message

set fish_greeting

FAQs

The FAQs is very nice. Be sure to check it out.

Follow me

Here's where I hang out in social media