Are you bored with the default terminal of Mac? Want to turn your terminal into something more interactive and colorful? Well here is the iTerm2 and oh-my-zsh for rescue.

iTerm2 is a Mac OS terminal replacement, download it from here or install it using homebrew by executing

1
2
brew install cask
brew cask install iterm2

Oh-My-Zsh is an open source, a community-driven framework for managing your zsh configuration.

Let’s utilize both to setup a customisable and interactive terminal development environment.

Step 1: Install iTerm2

Download and install the iTerm2.

Now change the default theme to Solarized Dark

1
Iterm2 -> Preferences -> Profiles -> Colors

Select the Solarized Dark from the color presets drop-down menu. If Solarized Dark option is not available then download the theme

1
2
cd ~/Downloads
wget https://raw.github.com/altercation/solarized/master/iterm2-colors-solarized/Solarized%20Dark.itermcolors

And then select the import option from the drop-down menu to import the theme.

There are few more tweaking we can do such as setting scroll back to unlimited and open existing file path in a text editor from the terminal by clicking on a link with command key.

Set an unlimited scroll back

1
Preferences -> Profiles -> Terminal

And check the unlimited scroll back option.

Select the editor for file opening

1
Preference -> Profile -> Advanced

In semantic history select open with editor and select your choice of editor from the drop-down menu.

Step 2: Install Zsh

Install zsh and zsh completions using homebrew

1
brew install zsh zsh-completions

Step 3: Install oh-my-zsh

You can install this via the command-line with either curl or wget.

via curl

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

via wget

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

Step 4: Basic configuration and install plugins

You can change the zsh configuration in .zshrc file placed in the home directory. Open the .zshrc file in your choice of editor, I am using vi editor in the below example

1
2
cd
vi ~/.zshrc

Find below line and set the theme to agnoster

1
ZSH_THEME="agnoster"

Now reload the configuration file to reflect the changes

1
source ~/.zshrc

If you find weird character on your terminal download and install Meslo font.

Now set iTerm2 to use this font

1
Preference -> Profiles -> Text

Click on change font, from family drop-down select meslo LG M DZ for powerline with font size 14.

It seems weird to see your username prepended in display path, let’s remove it.

Open .zshrc

1
2
cd
vi ~/.zshrc

Add following in the file

1
DEFAULT_USER=`whoami`

Let’s install some useful plugins.

Install zsh-syntax-highlighting

zsh-syntax-highlighting highlight the syntax with different colors.

1
brew install zsh-syntax-highlighting

Add in the end of .zshrc

1
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Install zsh-autosuggestions

zsh-autosuggestions suggest the command used in past. Use right arrow key to use command from the suggestion.

Clone the repo

1
2
cd
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

Then add zsh-autosuggestions in the plugins list inside .zshrc

1
plugins=(zsh-autosuggestions)

Reload the configuration file

1
source ~/.zshrc

Still, if you are not able to see the suggestion, add following line in the end of .zshrc

1
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=white'