iTerm2 oh-my-zsh Setup

iTerm2 oh-my-zsh 的设置

Posted by starwavelin on June 4, 2018

Mac’s own terminal environment has some issues, such as cannot split into panes, does not distinguish file and directory names.

Setting up iTerm2 and oh-my-zsh can give you a good way of using the terminal env.

Install iTerm2

Assume you have homebrew installed for your mac, just do

$ brew cask install iterm2

Homebrew is a good package management tool for Mac, highly recommended to install. You can find the installation command from

Install oh-my-zsh

You can find the curl command from to install oh-my-zsh

Like bash, Z shell (Zsh) is also a Unix shell.

Once you successfully installed oh-my-zsh, you are gonna see .zshrc being added to your ~ directory.

Font and Layout setting for oh-my-zsh

Now comes into the cool part, setup fonts and layout for your Zsh. The way I did was:

Install powerline fonts
git clone project
then CD to the directory of powerline fonts, install it using

$ sh ./

Change Preference for iTerm2
Colors: Solarized (light)
Font Family: DejaVu Sans Mono for Powerline
Style: Book
Size: 12pt

Change the ZSH THEME
In .zshrc, set


$ zsh
To refresh the Z shell pane

oh-my-zsh Sample Outcome

After the steps above, you can avoid $ pwd in the future

Update .zshrc file

Previously in order to invoke the environment variables already defined in .bash, I used a naive way by adding source ~/.bash_profile in .zshrc

Actually, I can just append environment variables into .zshrc directly cuz I am just launching iTerm2 with Zsh from now on.

For example, I can append node.js environment variables / commands to the end of .zshrc

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion