1. 程式人生 > >Mac下終端配置(item2 + oh-my-zsh + solarized配色方案)

Mac下終端配置(item2 + oh-my-zsh + solarized配色方案)

tro functions share pla all style tab col order

轉載自:http://www.cnblogs.com/weixuqin/p/7029177.html

安裝

首先我們下載的 iTem2 這個軟件,比Mac自帶的終端更加強大。直接官網 http://iterm2.com/ 下載並安裝即可。

配置

將iTem2設置為默認終端:

(菜單欄)iTerm2 -> Make iTerm2 Default Term

技術分享

然後打開偏好設置preference,選中Keys,勾選Hotkey下的Show/hide iTerm2 with a system-wide hotkey,將熱鍵設置為command+. ,這樣你就可以通過command+. 全局熱鍵來打開或關閉iTerm2窗口,非常方便。

技術分享

配色方案

我選用的是 solarized,效果還不錯。點開官網,下載,解壓,然後打開 iTerm2 下的偏好設置 preference ,點開 profiles 下的colors 選項,點擊右下角的 Color Presets 選項,選擇import ,導入解壓到的 solarized 文件下的Solarized Dark.itermcolors

安裝oh-my-zsh

github連接:https://github.com/robbyrussell/oh-my-zsh

使用 crul 安裝:

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

或使用wget:

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

主題

安裝成功後,用vim打開隱藏文件 .zshrc ,修改主題為 agnoster:

1 ZSH_THEME="agnoster"

應用這個主題需要特殊的字體支持,否則會出現亂碼情況,這時我們來配置字體:

1.使用 Meslo 字體,點開連接點擊 view raw 下載字體。

2.安裝字體到系統字體冊。

3.應用字體到iTerm2下,我自己喜歡將字號設置為14px,看著舒服(iTerm -> Preferences -> Profiles -> Text -> Change Font)。

4.重新打開iTerm2窗口,這時便可以看到效果了。

技術分享

到這步我們的終端看上去已經非常好看了,這時我們來安裝其它插件,讓終端看起來更加風騷。

自動提示命令

技術分享

當我們輸入命令時,終端會自動提示你接下來可能要輸入的命令,這時按 → 便可輸出這些命令,非常方便。

設置如下:

1.克隆倉庫到本地 ~/.oh-my-zsh/custom/plugins 路徑下

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

2.用 vim 打開 .zshrc 文件,找到插件設置命令,默認是 plugins=(git) ,我們把它修改為

1 plugins=(zsh-autosuggestions git)

3.重新打開終端窗口。

PS:當你重新打開終端的時候可能看不到變化,可能你的字體顏色太淡了,我們把其改亮一些:

移動到 ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions 路徑下

1 cd ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

用 vim 打開 zsh-autosuggestions.zsh 文件,修改 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=‘fg=10‘ ( fg=10 在我電腦上顯示良好)。

語法高亮

1.使用homebrew安裝 zsh-syntax-highlighting 插件。

1 brew install zsh-syntax-highlighting

2.配置.zshrc文件,插入一行。

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

3.輸入命令。

1 source ~/.zshrc

PS:安裝homebrew包管理工具:

1 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Mac下終端配置(item2 + oh-my-zsh + solarized配色方案)