Skip to content

Instantly share code, notes, and snippets.

@AD0791
Created October 20, 2021 05:16
Show Gist options
  • Save AD0791/d5730fdf2596329a3c8c77094da73a95 to your computer and use it in GitHub Desktop.
Save AD0791/d5730fdf2596329a3c8c77094da73a95 to your computer and use it in GitHub Desktop.
Fish setup

Installation

Install via homebrew and set fish as default shell.

brew install fish
echo /usr/local/bin/fish | sudo tee -a /etc/shells
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:

  • fisher
  • oh-my-fish
  • fundle

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment