[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2

A beautiful and colourful coding UI can make us happy.

  • For Shell, Life is short, I am ZSHer.
  • For Terminal, I chosen iTerm 2, instead of Terminal of Mac.

Below is my iTerm 2 UI.

[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第1张图片
iTerm 2, ZSH

iTerm 2

iTerm 2: Download
Download iTerm 2 from official site, unzip the ZIP file and put the iTerm 2 application to your preferred directory of your Mac, recommend store iTerm 2 application to directory /Application.

Transparency setting for iTerm 2

I like transparent UI in Terminal, so in this setup, setting transparency for iTerm 2.

  1. Open iTerm 2.
  2. Open Preferences of iTerm 2:
    • Click iTerm -> Preferences... at menu bar or
    • Press shortcut keys Command + ,.
  3. Tap Profile in Preferences.
  4. Select your preferred Profile at the left list view, the user profile list.
  5. Change Window Appearance -> Transparency as you prefer the transparency by scrolling the bar.
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第2张图片
Transparency of iTerm 2

Install oh-my-zsh

The Shell ZSH is better than Bash, and in Mac, the default Shell is Bash.
Installing oh-my-zsh, the installer will change the Shell from Bash to ZSH, and maybe the installation will ask you to input ROOT's password for the Shell changing, as change Shell need ROOT permission.
Enter the command below in iTerm 2 or Terminal to install oh-my-zsh:
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

Install Powerline

For display Non-ASCII characters, we need to install Powerline.
From official site of Powerline, to install Powerline just command run below:
pip install powerline-status
If no pip installed, you need to install pip first, the installation command is:
sudo easy_install pip

Fonts download and install: Powerline Fonts

  1. Download the project from Github and unzip it.
  2. Change directory to the directory just unzip �at step 1.
  3. Run ./install.sh to install all Powerline Fonts.

After the installation completed, all Powerline Fonts were installed to directory
/Users//Library/Fonts
and in iTerm 2 or Terminal, message can be saw:
All Powerline fonts installed to /User//Library/Fonts

Fonts Setting for iTerm 2: Regular Font, Non-ASCII Font

After Powerline Fonts installed, we can setting fonts to iTerm 2.
As mention above, Poweline Fonts is the solution for displaying Non-ASCII character in iTerm 2 or Terminal correctly, so I keep Regular Font default setting and set Non-ASCII Font to font Inconsolata for Powerline with 14pt.

  1. Open "Preferences" of iTerm 2.
  2. Goto Profile -> Text, you will find Regular Font and Non-ASCII Font settings.
  3. Click Change Font button in section Non-ASCII Font.
  4. Select fonts Inconsolata for Powerline and select the font size to 14pt.
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第3张图片
Fonts setting for Non-ASCII

Colour Scheme installation for iTerm 2: Solarized

  1. Download Solarized theme from Github, unzip it.
  2. Change directory to the upzip project folder and change directory to folder iterm2-colors-solarized.
  3. Double click the theme installation file to install the colour scheme for iTerm 2: Solarized Dark.itermcolors, Solarized Light.itermcolors.

Colour Scheme Setting for iTerm 2

After Solarized colour scheme installed, now can setup Solarized scheme to iTerm 2.
I like the dark style as the UI is not too sharp.

  1. Open Preferences of iTerm 2.
  2. Goto Profile -> Colors .
  3. Click dropdown menu Load Presets..., and select Solarized Dark.
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第4张图片
Setting Solarized Dark theme

Install theme Cobalt2

Why Cobalt2 and not Agnoster?
Agnoster theme, before prompt, display username, hostname, it is long.
Cobalt2 theme is hide username, hostname, so looks shorter for prompt.
Though can modify "Agnoster" configuration to hide username and hostname, stupid I chosen to install others theme.

  1. Download Cobalt2 project from Github, unzip it.
  2. Copy Cobalt2 project file cobalt2.zsh-theme to oh-my-zsh theme folder, the folder path is:
    ~/.oh-my-zsh/themes/
  3. Setting ZSH theme to Cobalt2, open ZSH setting file:
    vim ~/.zshrc.
  4. Change the theme setting to Cobalt2, change the value of variable ZSH_THEME to cobalt2.
    ZSH_THEME=cobalt2.

After ZSH theme set, run source to make the ZSH environment setting to activate:
source ~/.zshrc
Now you can check the iTerm 2 displaying in colourful, looks good.

[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第5张图片
Cobalt2 with hide username and hostname
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第6张图片
Agnoster with username and hostname

Install Syntax Highlight: ZSH Syntax Highlighting

Syntax highlighting is display entering command in GREEN colour if it is correct, otherwise in RED if it is incorrect.

  1. Change directory to .zshrc directory.
    Warm reminder, file .zshrc directory is current login user's home directory, you can change directory to your home directory by cd directory.
  2. Run git clone command to clone ZSH-Syntax-Highlighting project to the directory.
    git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
  3. Open .zshrc, and add the context below to the end of .zshrc:
    source XXX/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
    plugins=(zsh-syntax-highlighting)
    please note that, XXX = Directory of .zshrc.
    Save and quit .zshrc with :wq
  4. Source .zshrc:
    source ~/.zshrc
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第7张图片
ZSH-Syntax-Highlighting

Problem:

  1. Actually, one thing in Solarized scheme is trouble me, it is display the syntax of VIM is bad, it looks that no syntax highlighting for variables, value, etc., please check screenshot below.
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第8张图片
Looks no syntax highlight to VIM

Update (Mar -12 -2016)

Use Cobalt2 colour scheme can display VIM in colour.

  1. Download Cobalt2 project for iTerm 2 from Github.
  2. Double click Cobalt2 project file cobalt2.itermcolors to install Cobalt2 scheme.
  3. Change iTerm 2 colour scheme to Cobalt2.
[iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2_第9张图片
Cobalt2 colour scheme

Enjoy Coding.

你可能感兴趣的:([iTerm ZSH]Happy Coding: Colourful iTerm 2 + ZSH + Cobalt2)