ZSH / Oh My ZSH!
Configure ZSH as your default shell with Oh My Zsh for an enhanced terminal experience with themes and plugins
What is ZSH?
zsh is short for Z shell.
It is an interactive login shell initially designed in the 1990s for the Unix operating system. The Z shell is built on top of Bash and hence inherits all the original features and functions of the Bash shell and also has many other features of its own.
It is the default shell on macOS and that is why we will focus on getting it set up on your Mac machine.
Prerequisites
Installation
By default, macOS ships with zsh located in /bin/zsh.
Install zsh through Homebrew:
brew install zsh
Install Oh My Zsh:
Oh My Zsh runs on top of the default zsh shell to provide additional features within the
~/.zshrc config file:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Close your terminal session after installation.
Verify Your Installation
Open a new terminal session and confirm your installation:
zsh --version
Close your terminal session, then remember to finish your
Homebrew foundation setup.
Good to Know
Upgrade Oh My Zsh
omz update
Themes for Your Shell
Oh My Zsh comes bundled with a lot of themes. The default theme is robbyrussell, but
you can change it to any theme of your choice.
For a list of available themes, have a look at the Themes wiki.
- Open your
~/.zshrcconfig file (use an IDE like Visual Studio Code) - Look for the line
ZSH_THEME="robbyrussell" - Change to a theme of your choice and save the changes
- In terminal, activate the changes by running:
source ~/.zshrc
Fonts for Your Shell
For enhanced prompt themes, install a patched font. Nerd Fonts is the recommended option โ it includes Powerline glyphs plus thousands of additional icons.
# Install a Nerd Font via Homebrew (example: JetBrains Mono)
brew install --cask font-jetbrains-mono-nerd-font
See the Nerd Fonts website for the full list of available fonts.
Choose your desired font in Terminal preferences: Terminal > Preferences > Profiles > Text > Change Font
Plugins for Your Shell
Oh My Zsh comes bundled with many plugins (like git and docker) that only need to be
listed in your ~/.zshrc. Third-party plugins need to be cloned first:
zsh-autosuggestions:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
zsh-syntax-highlighting:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Add your plugins to ~/.zshrc:
Open your ~/.zshrc config file and look for the plugins section:
plugins=(git)
Add your additional plugins:
# too many plugins slow down shell startup
plugins=(
git
docker
zsh-syntax-highlighting
zsh-autosuggestions
)
Aliases for Your Shell
Aliases are shortcuts used to reduce the time spent on typing commands. Instead of typing the same command every time you use the terminal, you can set up an alias.
The following command reloads your terminal session:
eval exec zsh -l
Since this could be a frequent command, create an alias for it in your ~/.zshrc config
file:
alias reload_session="eval exec zsh -l"
In terminal, simply run reload_session and it will execute the command for you.
Aliases are loaded in your shell environment and will be auto-detected once youโve typed a portion of the alias and hit
tab.
History Configuration
By default, ZSH keeps history but does not deduplicate it. Add these settings
to your ~/.zshrc to keep history clean:
# Remove older duplicate entries when a new entry is added
setopt HIST_IGNORE_ALL_DUPS
# Avoid showing duplicates when searching history with Ctrl+R
setopt HIST_FIND_NO_DUPS
# Optional: increase history size (defaults are low)
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
These settings prevent the same command from cluttering your history.
HIST_IGNORE_ALL_DUPSremoves the older entry when a duplicate is added, whileHIST_FIND_NO_DUPSskips duplicates during reverse search.
Troubleshooting
zshrc is Damaged
Verify if the file has a quarantine flag:
xattr <path_to_the_document>
# output:
com.apple.quarantine
Remove the quarantine flag:
xattr -r -d com.apple.quarantine <path_to_the_document>
Terminal will ask you to enter your admin/login password. Verify that the flag is removed by re-running the former command.
Resources
Official Oh My Zsh wiki with installation, configuration, and FAQ
Browse the complete collection of Oh My Zsh themes
Explore available plugins to enhance your shell experience