.zshrc is your shell's configuration file. It runs every time you open Terminal, setting up your environment - aliases, PATH, prompt, and other customizations.
The name: "zsh" (the shell) + "rc" (run commands).
Where Is It?
~/.zshrc
The ~ means your home folder. The dot makes it hidden.
What Goes In It?
Common additions:
# Aliases (shortcuts for commands)
alias ll="ls -la"
alias gs="git status"
# PATH additions
export PATH="/opt/homebrew/bin:\$PATH"
# Environment variables
export EDITOR="nano"
# Prompt customization
PROMPT='%n@%m %~ %# '
Creating or Editing It
If it doesn't exist, create it:
touch ~/.zshrc
Edit it:
nano ~/.zshrc
Make changes, save (Control + O), exit (Control + X).
Applying Changes
After editing, either:
Reload the file:
source ~/.zshrc
Or open a new Terminal window - it loads automatically.
Common Uses
Aliases
Save typing with shortcuts:
alias ..="cd .."
alias ...="cd ../.."
alias la="ls -la"
alias c="clear"
alias h="history"
PATH Modifications
Add folders where commands live:
export PATH="\$HOME/bin:\$PATH"
export PATH="/opt/homebrew/bin:\$PATH"
Environment Variables
Set variables that programs use:
export EDITOR="nano"
export NODE_ENV="development"
Custom Prompt
Change how your prompt looks:
# Simple: username in directory
PROMPT='%n in %~ → '
# With colors
PROMPT='%F{green}%n%f:%F{blue}%~%f \$ '
.zshrc vs .zprofile
| File | When it runs |
|---|---|
.zshrc |
Every interactive shell (new Terminal window/tab) |
.zprofile |
Only login shells (less common) |
For most customizations, use .zshrc.
View Your Current .zshrc
cat ~/.zshrc
If it doesn't exist or is empty, that's fine - Mac works with defaults.
Example .zshrc
A practical starter config:
# Homebrew (Apple Silicon)
eval "\$(/opt/homebrew/bin/brew shellenv)"
# Aliases
alias ll="ls -la"
alias gs="git status"
alias gp="git push"
alias c="clear"
# Better history
HISTSIZE=10000
SAVEHIST=10000
setopt SHARE_HISTORY
# Editor
export EDITOR="nano"
Backup Before Major Changes
Before experimenting:
cp ~/.zshrc ~/.zshrc.backup
If something breaks:
cp ~/.zshrc.backup ~/.zshrc
source ~/.zshrc
Common Mistakes
Syntax errors: One typo can break your Terminal. If Terminal acts strange after editing, check your recent changes.
Forgetting to reload: Changes don't apply until you source ~/.zshrc or open a new Terminal.
Breaking PATH: If you overwrite PATH instead of appending to it, commands stop working. Always use export PATH="/new/path:\$PATH" (keep the \$PATH part).
Keep Learning
Your .zshrc is where Terminal becomes truly yours. The free course covers these customizations and more.
Check it out at Mac Terminal for Humans.