Zsh & Fish Shell Config Cheat Sheet

Quick reference guide for Zsh & Fish Shell: Configuration files, aliases, custom prompts, functions, and environment variables.

CLI & Shell
zsh
fish
shell

Zsh (Z Shell) and Fish (Friendly Interactive Shell) are advanced interactive command-line shells offering auto-suggestions, tab completion, and customizable prompts.

Configuration Files Location

Table
ShellUser Config FileGlobal System Config
Zsh~/.zshrc/etc/zshrc
Fish~/.config/fish/config.fish/etc/fish/config.fish

Syntax Comparison (Zsh vs Fish)

Table
TaskZsh Syntax (.zshrc)Fish Syntax (config.fish)
Set Env Varexport PATH="$HOME/bin:$PATH"fish_add_path $HOME/bin
Create Aliasalias gs="git status"alias gs="git status"
Define Functionmkcd() { mkdir -p "$1" && cd "$1"; }function mkcd; mkdir -p $argv[1]; and cd $argv[1]; end
If Conditionif [ -d "$DIR" ]; then ... fiif test -d $DIR; ...; end

Custom Functions Examples

bash
# Zsh function (~/.zshrc)
extract() {
  if [ -f $1 ]; then
    case $1 in
      *.tar.bz2) tar xjf $1 ;;
      *.tar.gz)  tar xzf $1 ;;
      *.zip)     unzip $1 ;;
      *)         echo "'$1' cannot be extracted" ;;
    esac
  fi
}
fish
# Fish function (~/.config/fish/functions/extract.fish)
function extract
    switch $argv[1]
        case '*.tar.gz'
            tar xzf $argv[1]
        case '*.zip'
            unzip $argv[1]
        case '*'
            echo "'$argv[1]' cannot be extracted"
    end
end

Common Pitfalls & Tips

[!WARNING] Fish shell is not POSIX compliant! Standard Bash/Zsh scripts using export VAR=val or for i in {1..5} will fail when pasted directly into Fish shell.

[!TIP] Use Oh My Zsh or Starship prompt (starship init zsh) to instantly add Git branch status and execution timers to your shell prompt.