[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 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.
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/<Your Home Directory>/Library/Fonts
and in iTerm 2 or Terminal, message can be saw:
All Powerline fonts installed to /User/<Your Home Directory>/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.
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.
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.

Cobalt2 with hide username and hostname
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
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.
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.
Cobalt2 colour scheme

Enjoy Coding.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 197,000评论 5 462
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 82,825评论 2 374
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 144,055评论 0 325
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,766评论 1 267
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,639评论 5 358
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,453评论 1 275
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,860评论 3 388
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,492评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,783评论 1 293
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,817评论 2 314
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,624评论 1 328
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,439评论 3 316
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,872评论 3 300
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,075评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,372评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,868评论 2 343
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,075评论 2 338

推荐阅读更多精彩内容