Using Zsh and Oh My Zsh it is easy to customize your shell. You can install useful plugins or can easily change the font and color of your terminal.
In this article, we will use Homebrew to install Zsh and set it up to use Homebrew’s Zsh instead of the standard one installed in our Mac. After that, we install Oh My Zsh and add a few useful plugins.
Install Zsh using Homebrew
From macOS Catalina Zsh, Zsh became the default login shell and interactive shell, so if you are using macOS Catalina or above, you can skip this step of installing Zsh and setting Homebrew’s Zsh as the default.
First, install Zsh using homebrew.
brew update
brew install zsh
Setup to use brew’s Zsh
Open the file by using the below command.
sudo vi /etc/shells
add /usr/local/bin/zsh
to the list.
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells./bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/zsh
Change default terminal
Now that /user/local/bin/zsh
is added, change the default terminal to use that one instead.
chsh -s /usr/local/bin/zsh
After changing it, reopen the terminal and it should look like the image below:
Press the enter key and to see if the installation of homebrew Zsh is completed use the below command.
echo $SHELL
It should give the following result:
/usr/local/bin.zsh
That is it for setting up Homebrew’s Zsh as the default shell.
Install Oh My Zsh
After installing Zsh or if you are using macOS Catalina or above you could skip the above step as the default is Zsh, we will now install the Oh My Zsh framework for managing our Zsh configuration.
We install it using the following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
After it is installed, we should see something like the image below:
Install plugins
One of the great things about Oh My Zsh is that we can customize Zsh using plugins. Let us install some of the most useful ones. These are as follows:
Git clone the above three plugins
To use plugins, first clone the repositories to your local.
zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
zsh-completions
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
zsh-autosuggestion
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Setup the plugins in ~/.zshrc
Open ~/.zshrc file
vim ~/.zshrc
Add the names of the cloned repositories to the plugin list.
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
zsh-completions
)
For zsh-completions
add one more line just below plugins, as follows:
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
zsh-completions
)# command for zsh-completions
autoload -U compinit && compinit
After saving ~/.zshrc
with the plugins and command for zsh-completions, reload the terminal.
source ~/.zshrc
The plugins should be working now.
This is is for the setup of Zsh with Oh My Zsh using Homebrew. If you have any other useful plugins let me know in the comments.