macOS Zsh Terminal Colorization Guide

Complete walkthrough to switch to Zsh, customize prompt colors, and add background contrast

1 Ensure You Are Using Zsh

macOS defaults to Zsh since macOS Catalina. If your terminal was running bash, switch to Zsh first:

Run the switch command:

chsh -s /bin/zsh

If you prefer using the macOS Terminal UI:

  1. Go to Terminal > Settings (or Preferences) > General.
  2. Set "Shells open with" to Command (complete path).
  3. Enter /bin/zsh and restart Terminal.

Verify by checking the top bar of your Terminal window or running echo $SHELL. It should indicate zsh.

2 Open Your Zsh Configuration File

Open (or create) the .zshrc file in your user home directory using TextEdit:

touch ~/.zshrc; open -e ~/.zshrc

3 Add the Custom Colorized Prompt

To combine colored text for your username & machine with a solid blue background block for your path, add these lines to your .zshrc file:

# Enable prompt variable substitution
setopt prompt_subst

# Custom colored prompt with contrasting path background
export PROMPT='%F{cyan}%n%f@%F{green}%m%f:%K{blue}%F{white} %~ %f%k %# '

# Enable colors for file/directory listings (ls)
export CLICOLOR=1
export LSCOLORS=Gxfxcxdxbxegedabagacad

Visual Preview of Your New Prompt:

username@macbook-name: ~ %

4 Zsh Formatting Syntax Reference

Code Meaning / Action
%n Username
%m Hostname / Machine Name
%~ Current Working Directory Path (uses ~ for home)
%F{color} / %f Start Foreground (Text) Color / Reset Text Color
%K{color} / %k Start Background Block Color / Reset Background Color
%# Prompt symbol (% for standard user, # for root)

5 Save and Apply Changes

1. Save the file in TextEdit (Cmd + S) and close it.

2. Reload your configuration in Terminal by running:

source ~/.zshrc

Conda / Anaconda Note: If you see (base) in front of your prompt, Conda is active. The custom prompt above preserves your formatting and path colors alongside Conda environment indicators.