Skip to content

Setting up my fish shell from scratch on macOS

Drew Bell
2 min read
Setting up my fish shell from scratch on macOS
neofetch

Table of Contents

I had to re-install macOS and I couldn't remember how to set up the fish shell with my preferred config.

Below are my notes on setting it up 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

Add Homebrew to the PATH env var

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-solarized-light

Changing the prompt

I simply use starship with default settings here. Starship requires a Nerd-Font to display all the 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 your fish config

#Starship setup
starship init fish | source

Basic improvements

bat is a replacement for cat and makes it far easier to quickly read file. It has syntax highlighting and line numbering

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 the fish config file ~/.config/fish/config.fish 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. Here is an example of the improved experience.

Likewise, when you type ls it will immediately be replaced with eza --long --classify --all --header --git --no-user --tree --level 1

fishshellmacos

Related Posts

Generating DNS Stamps

Encrypted DNS support was added to Ubiquiti’s UniFi Network service in a recent update. I was excited to finally have this feature appear in the UI rather than having to run 3rd party scripts to get this to work. However DNS-over-TLS (DoT) and DNS-over-HTTPS (DoH) were strangely absent from