2 minute read

As a software engineer, we spend significant amount of time in terminal. Terminal in Mac OSX is better than windows but not as good as iTerm2. If you combine iTerm with Zsh and Oh-My-Zsh then what you get is awesomeness.

Install iTerm2

Download a stable build from https://www.iterm2.com/downloads.html and install it.

Install Brew

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system.

Now, open iTerm and install brew using following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install and Configure Fira Code Font

Fira Code is an extension of the Fira Mono font containing a set of ligatures for common programming multi-character combinations. This is just a font rendering feature: underlying code remains ASCII-compatible. This helps to read and understand code faster.

Without Fira Code

With Fira Code and Ligature

To install Fira Code, run following command:

brew tap homebrew/cask-fonts
brew cask install font-fira-code

ProTip: Fira Code font is supported in multiple editors and terminals. Checkout complete list on Fira Code site

Setup Font in iTerm

Step 1. Open Preferences in iTerm by pressing and , keys

Step 2. Go to Profile tab and create a new profile

Step 3. Go to Text tab. Change font and ASCII font to Fira Code and enable use of ligature

Install Zsh

Once you have brew installed, you can install zsh using following command:

brew install zsh

Install and Configure Oh-My-Zsh

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes and much more.

Install Oh-My-Zsh using following command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Set Theme

There are whole lot of themes to choose from here. My personal customized theme is based on bira theme. Also, I have another slightly modified theme based on agnoster theme. Change ZSH_THEME=robbyrussell to ZSH_THEME=YOUR_FAV_THEME_NAME into ~/.zshrc file. After change reload shell by:

source ~/.zshrc

Enable plugins

There’s an abundance of plugin in Oh-my-zsh. You can find list of plugins here. Most of the plugins provide autocompletion for command options on press of ⇥ tab key (demo). You can turn on plugins by updating plugins section in ~/.zshrc file like following:

plugins=(brew git ruby aws virtualenv)

Install zsh syntax highlighting and auto suggestions plugins if you are interested in these functionality.

brew install zsh-syntax-highlighting zsh-autosuggestions

Add following lines to end of the ~/.zshrc file. You can pick and choose from last 3 lines, based on the plugin you have installed.

export VIRTUAL_ENV_DISABLE_PROMPT=
export LC_CTYPE=en_GB.UTF-8
export TERM="xterm-256color"
export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor line)
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh

ProTip: To reload any change made in ~/.zshrc file, use source ~/.zshrc command.

Working with Alias

Alias is not exclusive functionality of zsh but Oh-my-zsh provides lots of alias by default. Lots of plugins also come with alias for example git plugin.

If you want to create your on aliases, create a separate file and load that file using ~/.zshrc by adding following line in the file:

source PATH_TO_YOUR_FILE

To list all the avaliable alias use command alias in the terminal.

HotKeys

If your hotkeys for moving backward (⌥ option + ) and forward (⌥ option + ) word by word do not work in iTerm then change keys preset in your profile to Natural Text Editing.

Leave a Comment