Installing ZSH and Oh My Zsh on Mac and Linux
Let’s supercharge your terminal with ZSH and Oh My Zsh. Here’s how to install them on macOS and popular Linux distributions.
What are ZSH and Oh My Zsh?
- ZSH (Z Shell): a powerful, extensible shell that can replace bash
- Oh My Zsh: a framework for managing ZSH configuration, with themes, plugins, and more
Installing ZSH
On macOS
Check if ZSH is already installed (it’s the default since macOS Catalina):
zsh --version
If needed, install via Homebrew:
brew install zsh
On Linux
Install according to your distribution:
# Ubuntu/Debian
sudo apt update
sudo apt install zsh
# Fedora
sudo dnf install zsh
# Arch Linux
sudo pacman -S zsh
# CentOS/RHEL
sudo yum update
sudo yum install zsh
Make ZSH your default shell
chsh -s $(which zsh)
Log out and back in to apply the change.
Install Oh My Zsh
Using curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Using wget
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
Customize your terminal
Change the theme
Edit your .zshrc:
nano ~/.zshrc
Set a theme, for example:
ZSH_THEME="agnoster"
Other popular themes: robbyrussell, agnoster, avit, bira, fino, jonathan.
Add plugins
In .zshrc:
plugins=(git docker composer npm sudo web-search)
Recommended plugins for developers
git,composer,laravel,npm,docker,vscode
(Optional) Install Powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Then set in .zshrc:
ZSH_THEME="powerlevel10k/powerlevel10k"
Restart the terminal to run the configuration wizard.
You now have a faster, more productive terminal. Try different themes and plugins to match your workflow. You can always switch back to bash with bash if needed.