Complete walkthrough to switch to Zsh, customize prompt colors, and add background contrast
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:
/bin/zsh and restart Terminal.Verify by checking the top bar of your Terminal window or running echo $SHELL. It should indicate zsh.
Open (or create) the .zshrc file in your user home directory using TextEdit:
touch ~/.zshrc; open -e ~/.zshrc
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:
| 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) |
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.