Better MacOS Terminal for Programmers
👋 Introduction
Terminal application is one of the most important, if not, the most important application in MacOS. Although MacOS has several built-in shells, most of the time users use either zsh
or bash
shells. To check which terminal you are using on Mac, simply open your terminal and type,
echo $SHELL
In this article, we will be looking at how you can configure MacOS’s built-in zsh
terminal. To check whether the zsh
terminal is on your Mac, type the following command.
cat /etc/shells | grep "zsh"
If you have confirmed that you have zsh
shell installed in your Mac you are all set for spicing up the Mac terminal. But if you are not, you have to install zsh
terminal. You can install it with brew install zsh
But for that, you need to have Homebrew installed on your machine. Homebrew is a package manager tool for MacOS and we need that to make changes to our zsh
shell as well.
🍺 Installing Homebrew
To install Homebrew you can simply follow the below given instructions.
Run
/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
)"
to install Homebrew.After the installation, it will provide two commands to run in the terminal as on-screen instructions.
1st command →
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<username>/.zprofile
2nd command →
eval "$(/opt/homebrew/bin/brew shellenv)"
Type
brew
in your terminal to confirm you have installed Homebrew correctly.
💻 Install zsh
If you did not have zsh
terminal when you ran cat /etc/shells | grep "zsh"
, you can install zsh
with Homebrew by typing brew install zsh
After the installation confirm you have zsh
terminal by typing cat /etc/shells | grep "zsh"
one more time.
After that, change the default terminal to zsh
terminal by typing the below command.
chsh -s /bin/zsh
Restart your terminal to check whether the changes are applied correctly.
🎨 oh-my-zsh
Now let’s make our terminal colorful 🎨 To do that follow the below given instructions.
Install git→
brew install git
Install oh-my-zsh →
sh -c "$(curl -fsSL
https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
)"
Download and install the fonts that we need in our terminal →
https://github.com/Falkor/dotfiles/blob/master/fonts/SourceCodePro%2BPowerline%2BAwesome%2BRegular.ttf
Install powerlevel10k theme →
git clone
https://github.com/romkatv/powerlevel10k.git
$ZSH_CUSTOM/themes/powerlevel10k
Open
.zshrc
file withopen ~/.zshrc
and update the$ZSH_THEME
there with powerlevel10k →ZSH_THEME="powerlevel10k/powerlevel10k"
Relaunch the terminal and follow the on-screen instructions to make your terminal beautiful 🌈✨
🤔 auto-suggestions
In addition to making your terminal beautiful, you can also use auto-suggestions with your zsh
terminal as well. To use the auto-suggestion capability, simply follow the below-given instructions.
Clone git repository and install →
git clone
https://github.com/zsh-users/zsh-autosuggestions
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Update
.zshrc
file →plugins=(zsh-autosuggestions)
(If you already havegit
in theplugins
section,plugins=(git zsh-autosuggestions)
Source
.zshrc
file →source ~/.zshrc
There you go! Now you have a beautiful and better terminal to work with your projects from now on! 😊
📚References
Subscribe to my newsletter
Read articles from Nipuna Upeksha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by