Setting up fish shell from scratch on macOS

Setup
Install Fish
Run the following command to install Fish
brew install fish
Set fish as the default shell
echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/fish
restart your terminal for changes to take effect
Add Homebrew to the PATH env variable
fish_add_path "/opt/homebrew/bin/"
Create completion files
fish_update_completions
Customisations
Change the colour scheme
I like to use the base-16-shell git repo to set up Solarized theme. By setting it this way, I edit it one time in the shell config file and not per terminal emulator.
Installation
git clone https://github.com/chriskempson/base16-shell.git ~/.config/base16-shell
Configuration
Add the following lines to the fish config ~/.config/fish/config.fish
# Base16 Shell
if status --is-interactive
set BASE16_SHELL "$HOME/.config/base16-shell/"
source "$BASE16_SHELL/profile_helper.fish"
end
base16_solarozed-light
Changing the prompt
I simply use starship with default settings here. Starship requires a Nerd-Font to display all the prompt information correctly.
Installation
I prefer to use the Hack Nerd-Font and both Starship and Nerd-Fonts can be installed with HomeBrew
brew install --cask font-hack-nerd-font
brew install starship
Configuration
First, open your terminal settings and set the default font to your preferred Nerd-Font
Next, add the following lines to the end of your fish config file
#Starship setup
starship init fish | source
Basic Improvements
bat is a replacement for cat
and makes it far easier to quickly read files. It has syntax highlighting and line numbering straight out of the box.
eza is a replacement for the venerable ls
command. It uses colours to distinguish file types and metadata . it knows about symlinks, extended attributes and Git.
Installation
brew install bat eza
Configuration
In your fish config file add the following lines
# `ls` → `eza` abbreviation
# Requires `brew install eza`
if type -q eza
abbr --add -g ls 'eza --long --classify --all --header --git --no-user --tree --level 1'
end
# `cat` → `bat` abbreviation
# Requires `brew install bat`
if type -q bat
abbr --add -g cat 'bat'
end
Once you restart your terminal or source your fish config file, when you type cat
it will automatically replace the command with bat
. Likewise when you type ls it will replace it with eza --long --classify --all --header --git --no-user --tree --level 1
This is the basic setup I use across all my machines