昨天配置了一下自己的iTerm,最后的效果確實(shí)顏值飆升,終端的使用也方便了許多。非常感謝簡(jiǎn)書的@SuperDanny,本文主要是對(duì)他的教程中遇到問(wèn)題的注解,方便以后查閱。
首先上效果圖:

效果圖
-
1.下載安裝 iTerm
-
2.將默認(rèn)bash切換為zsh
chsh -s /bin/zsh
-
3.cd到根目錄,安裝oh-my-zsh
cd ~ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
-
4.留在根目錄,安裝Powerline
這里推薦使用pip安裝
pip install powerline-status --user
添加
--user
防止因權(quán)限問(wèn)題安裝失敗 -
5.下載、安裝字體庫(kù)
- 字體庫(kù)
- 推薦采用方式為:cd到根目錄,clone本項(xiàng)目
- cd到項(xiàng)目目錄,執(zhí)行
./install.sh
,安裝所有Powerline字體
安裝完成后,可看到提示
All Powerline fonts installed to /Users/superdanny/Library/Fonts
-
6.設(shè)置iTerm的Regular Font 和 Non-ASCII Font
- 安裝完字體庫(kù)之后,把iTerm 2的設(shè)置里的Profile中的Text 選項(xiàng)卡中里的Regular Font和Non-ASCII Font的字體都設(shè)置成 Powerline的字體,我這里設(shè)置的字體是12pt Meslo LG S DZ Regular for Powerline。
-
7.配色方案
-
安裝配色方案
進(jìn)入剛剛下載的工程的solarized/iterm2-colors-solarized 下雙擊 Solarized Dark.itermcolors 和 Solarized Light.itermcolors 兩個(gè)文件就可以把配置文件導(dǎo)入到 iTerm中
-
配置配色方案
通過(guò)load presets選擇剛剛安裝的配色主題即可
-
-
8.使用agnoster主題
-
依舊推薦cd到根目錄,clone方式安裝
-
cd到agnoster目錄,運(yùn)行install文件
open install
-
設(shè)置該主題
在根目錄,編輯
.zshrc
文件vim .zshrc
將
ZSH_THEME
后面的字段改為agnoster
。ZSH_THEME="agnoster"
(agnoster即為要設(shè)置的主題)
-
-
9.增加指令高亮效果—zsh-syntax-highlighting
指令高亮效果作用是當(dāng)用戶輸入正確命令時(shí)指令會(huì)綠色高亮,錯(cuò)誤時(shí)命令紅色高亮
cd到根目錄
clone方式安裝項(xiàng)目
-
再次編輯
.zshrc
文件,添加下面內(nèi)容source ~/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
-
cd到plugins目錄
cd ~/.oh-my-zsh/custom/plugins
-
編輯
.zshrc
文件注意,此時(shí)在plugins目錄下,此zshrc為本目錄下的zshrc文件
在本zshrc文件中,添加下面內(nèi)容:
plugins=(zsh-syntax-highlighting)
-
cd到根目錄,執(zhí)行source指令
source .zshrc
至此,重啟iTerm,即可看到設(shè)置生效。