Configure my Iterm2

4 minute read

Published:

That was really impressed by the color theme of the Prof Xia’s terminal. I just configured my Iterm2 this morning. This article illustrates the process step by step.

Iterm2 and Oh My Zsh

ITerm2 is an awesome terminal tool customized for Mac users which can replace the native MacOS terminal. ITerm2 serves as a simulator so we still need a shell.

When it comes to shell, bash is well-known in that it is the default shell of Linux. Bash is not powerful and has poor auto-complete function which is quite important for a hacker. Zsh, which means “the last shell you’ll ever need”, makes up for deficiencies of bash. However, the complex configuration of Zsh disappoints users. Oh My Zsh appears as the improved one of Zsh. Oh My Zsh is both powerful and handy.

ITerm2 cooperates with Oh My Zsh to make your terminal amazing.

The configuration of ITerm2

The installation of iTerm2 is easy, like any App you install on Mac.

I choose Solarized as the theme. You can change your theme following Preferences -> Profiles -> Colors -> Color Presets.

Then you can highlight the dictionary by going to Preferences -> Profiles -> Text -> Text Rendering and uncheck the option Draw bold text in bright colors.

To show the proper characters in the terminal, you should also install Powerline font.

I follow the instructions on the https://github.com/powerline/fonts.

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

I entered these instructions but it still doesn’t work in the terminal. Some certain symbols are replaced by some weired symbols such as ?.

In this case, go to Preferences -> Profiles -> Text -> Change font to select the fonts suffixed with “for Powerlines” such as “12pt Meslo LG S DZ Regular for Powerlines”.

Now the configure of iTerm2 is finished.

The configuration of OhMyZsh

First, check if you have installed OhMyZsh.

cat /etc/shells

...
...
/bin/bash
/bin/sh
/bin/zsh
...
...

If you get this result, it shows that you have installed zsh and OhMyZsh.

You can download any theme you like from the official site and add the file under ~/.oh-my-zsh/themes.

Then modify ~/.zshrc and change ZSH_THEME. My file ~/.zshrc shows as follows. You need to change ZSH_THEME in the 9th line.

vi ~/.zshrc

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/wuzhengyu/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="lambda-mod"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
"~/.zshrc" 98L, 3404C

The default theme is robbyrussell. Here I have set it to lambda-mod. Popular theme includes agnoster. Someone naughty makes the theme random.

ZSH_THEME="random" # (...please let it be pie... please be some pie..)
And if you want to pick random theme from a list of your favorite themes:

And you can pick random theme from a list:

ZSH_THEME_RANDOM_CANDIDATES=(
  "robbyrussell"
  "agnoster"
)

OhMyZsh has many amazing features. For example, entering d will show the recent path you visited. Enter the conresponding path number then you will go to that path.

Explore your terminal and enjoy hacking.