Upgrade your Mac Terminal using iTerm2 and Zsh
The Mac Terminal is used frequently by programmers to perform all sorts of programming actions, so it helps to look as cool as the operator from The Matrix while using it. By default though, the terminal looks plain and doesn’t help you at all with its limited information and bland design. Zsh also known as Z Shell is a shell built on top of the default shell for macOS(bash).
Zsh has huge number of features, and when combined with iTerm, it becomes a beast for programming and productivity. Let’s take a look at how we can setup our Mac Terminal to give us the information we need, helping us excel at working productively in a fashionable (and sexy) way.
1. Homebrew
If you have a Mac OS and have with Terminal for some time, you most likely already have Homebrew installed. Otherwise, go ahead and install homebrew using the command below.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. iTerm2
iTerm2 has much better features compared to the default terminal in macOS and most programmers prefer using it. The latest version of iTerm is iTerm2. Install iTerm2 using the following command:
brew cask install iterm2
3. Zsh
MacOS ships with zsh by default and you don’t need to do anything. But if your system doesn’t have the zsh configuration, we will need to install it for the next steps to follow.
Run the following command to install zsh:
brew install zsh
4. Oh My Zsh
Oh My Zsh is a framework for managing your zsh configuration. It allows you to configure zsh easily. Install Oh My Zsh using this command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
5. Theme your Zsh
Your zsh should already be looking pree cool with the default robbyrussell theme, but if you feel like spicing things up and look like a pro, use a custom theme. One popular custom theme for zsh is powerlevel9k. Let’s clone this repository:
$ git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
Once the themes are cloned, go ahead and update your zsh configuration to change the theme to powerlevel9k.
Open the zsh configuration using the command:
open ~/.zshrc
Once the file is open, replace the existing theme with powerlevel9k, by editing this line:
ZSH_THEME="powerlevel9k/powerlevel9k"
Save the file and update your changes:
source ~/.zshrc
Now the fun begins. To change the colors and appearance, you can navigate to Preferences > Profiles > Colors and play around with colors or you can use pre-built color scheme. Go ahead and download the zip file of Color Schemes. Extract the zip file.
Next, go to the colors inside profiles from preferences and import the color schemes by clicking on Color Presets.
6. Custom Fonts
Download a preferred font from powerline fonts and install it. Change the font from preferences menu to the font you just downloaded. If your font supports ligatures, check the “Use ligatures” option to enable ligature in your terminal. Ligatures are really cool features of fonts. Fira code is one such open source font that supports ligatures.
7. Customize your Prompt
By the time you finish this setup. You will have prompts appearing on both sides of the terminal. If you'd like to customize how the prompts look, open your zsh configuration:
open ~/.zshrc
After the theme option. Add following lines:
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh dir dir_writable vcs)
Feel free to take a look at the features that you can change here. Once you are done with this, save the file and update the changes by running the command:
source ~/.zshrc
Congrats! Now you have a cool (and sexy) looking terminal. Go to a crowded cafe and hack away on the Terminal to make everyone around you jealous!