Fundamentals 11 min read

Unlock the Power of Fish Shell: Install, Switch, and Customize on macOS

This guide walks you through installing Fish Shell on macOS, switching from Bash or Zsh, configuring it as the default shell, and leveraging its modern features such as syntax highlighting, auto‑suggestions, web‑based configuration, and custom prompts for a more efficient command‑line experience.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Unlock the Power of Fish Shell: Install, Switch, and Customize on macOS

Introduction

Fish Shell is a modern command‑line interface praised for built‑in features like syntax highlighting, smart suggestions, and a web‑based configurator. It aims to make terminal work more pleasant and efficient for both newcomers and experienced users.

Installation

On macOS, install Fish via Homebrew: brew install fish The installation path is shown in the screenshot and may be needed later.

Switching Shells

Start Fish manually: fish Exit back to the previous shell with:

exit

Setting Fish as the Default Shell

First add the Fish binary to /etc/shells (replace {fish_path} with the actual installation path): sudo vim /etc/shells Append a line such as: {fish_path}/bin/fish Then change the default shell with chsh:

chsh -s /opt/homebrew/Cellar/fish/3.6.1/bin/fish

To revert, run: chsh -s /bin/zsh or chsh -s /bin/bash Note: Because Fish syntax differs significantly from Bash, it is recommended not to set Fish as the system default for scripts; use it interactively instead.

Handy Features

Syntax Highlighting

Valid commands appear in blue, errors in red, valid paths are underlined, and mismatched brackets or commas are highlighted.

Auto‑Completion Suggestions

Fish shows gray suggestions after you type a command. Accept a suggestion with ->, or a partial suggestion with Alt + ->.

Tab Completion

Press Tab after a partial command to list possible completions, including subcommands and options (e.g., git and its flags).

Web‑Based Configurator

Run fish_config to open a browser UI where you can adjust themes, prompts, functions, constants, history, and key bindings. The UI provides several preset themes and allows custom prompt configuration.

Custom Configuration File

Fish loads ~/.config/fish/config.fish on startup. You can add aliases, functions, and other settings here. Example of adding Git aliases:

vim ~/.config/fish/config.fish
alias g "git"
alias gst "git status"
alias grs "git reset --soft"
alias grh "git reset --hard"
alias gb "git branch"
alias gba "git branch -a"
alias gl "git pull"
if status is-interactive
  # interactive commands go here
end

After reloading Fish, the new aliases are available.

Prompt Customization

Create a fish_prompt function in config.fish to define a personalized prompt. The example below shows a prompt that displays the date, current directory, and Git branch status with colored symbols.

function fish_prompt
  set -f __prompt_data (set_color -o 46C74B "["(date "+%H时%M分%S秒")(set_color -o 46C74B) "]")
  set -f __prompt_pwd " "(set_color 00FF00)(prompt_pwd --full-length-dirs=10)
  if git_is_repo
    set -g __fish_git_prompt_char_stagedstate "●"
    set -g __fish_git_prompt_char_dirtystate "✚"
    set -g __fish_git_prompt_char_cleanstate "✔"
    __fish_git_prompt 2 >/dev/null
    set -f __informative_status (set_color -o bryellow)(__fish_git_prompt_informative_status)
    set -f __branch (set_color brred)(git_branch_name)
    set -f __prompt_git_info (set_color FF4BFF) " ("(git_branch_name) ": "(set_color red)$__informative_status(set_color FF4BFF)")"
  else
    set -f __prompt_git_info ""
  end
  echo (set_color 00BA00) "┬─"$__prompt_data$__prompt_pwd$__prompt_git_info(set_color normal)
  echo (set_color 00BA00) "╰─>"(set_color FF635C) "\$ "
end
if status is-interactive
end

The resulting prompt shows a colored timestamp, path, and Git status. You can also include the username via the $USER variable.

Greeting Modification

Define a fish_greeting function in ~/.config/fish/config.fish to change the welcome message displayed when Fish starts:

function fish_greeting
  echo Hello friend!
  echo The time is (set_color yellow; date +%T; set_color normal) and this machine is called $hostname
end
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

fish-shellShellInstallationmacOScustomizationcommand-line
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.