效果如下:
擁有語法高亮,命令行tab補(bǔ)全,自動提示符楞泼,顯示Git倉庫狀態(tài)等功能驰徊。
安裝
首先我們下載的 iTem2 這個軟件,比Mac自帶的終端更加強(qiáng)大堕阔。直接官網(wǎng) http://iterm2.com/ 下載并安裝即可棍厂。
配置
將iTem2設(shè)置為默認(rèn)終端:
(菜單欄)iTerm2 -> Make iTerm2 Default Term
然后打開偏好設(shè)置preference,選中Keys超陆,勾選Hotkey下的Show/hide iTerm2 with a system-wide hotkey牺弹,將熱鍵設(shè)置為command+. ,這樣你就可以通過command+. 全局熱鍵來打開或關(guān)閉iTerm2窗口时呀,非常方便张漂。
配色方案
我選用的是 solarized,效果還不錯谨娜。點(diǎn)開官網(wǎng)航攒,下載,解壓瞧预,然后打開 iTerm2 下的偏好設(shè)置 preference 屎债,點(diǎn)開 profiles 下的colors 選項仅政,點(diǎn)擊右下角的 Color Presets 選項垢油,選擇import ,導(dǎo)入解壓到的 solarized 文件下的Solarized Dark.itermcolors圆丹。
安裝oh-my-zsh
github連接:https://github.com/robbyrussell/oh-my-zsh
使用 crul 安裝:
`sh -c ``"$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"`
或使用wget:
`sh -c ``"$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"`
主題
安裝成功后滩愁,用vim打開隱藏文件 .zshrc ,修改主題為 agnoster:
`ZSH_THEME=``"agnoster"`
應(yīng)用這個主題需要特殊的字體支持辫封,否則會出現(xiàn)亂碼情況硝枉,這時我們來配置字體:
1.使用 Meslo 字體,點(diǎn)開連接點(diǎn)擊 view raw 下載字體倦微。
2.安裝字體到系統(tǒng)字體冊妻味。
3.應(yīng)用字體到iTerm2下,我自己喜歡將字號設(shè)置為14px欣福,看著舒服(iTerm -> Preferences -> Profiles -> Text -> Change Font)责球。
4.重新打開iTerm2窗口,這時便可以看到效果了拓劝。
到這步我們的終端看上去已經(jīng)非常好看了雏逾,這時我們來安裝其它插件,讓終端看起來更加風(fēng)騷郑临。
自動提示命令
當(dāng)我們輸入命令時栖博,終端會自動提示你接下來可能要輸入的命令,這時按 → 便可輸出這些命令厢洞,非常方便仇让。
設(shè)置如下:
1.克隆倉庫到本地 ~/.oh-my-zsh/custom/plugins 路徑下
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions.git
2.用 vim 打開 .zshrc 文件典奉,找到插件設(shè)置命令,默認(rèn)是 plugins=(git) 妹孙,我們把它修改為
plugins=(zsh-autosuggestions git)
3.重新打開終端窗口秋柄。
PS:當(dāng)你重新打開終端的時候可能看不到變化,可能你的字體顏色太淡了蠢正,我們把其改亮一些:
移動到 ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions 路徑下
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 插件嚣崭。
brew install zsh-syntax-highlighting
2.配置.zshrc文件笨触,插入一行。
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
3.輸入命令雹舀。
source ~/.zshrc
PS:安裝homebrew包管理工具:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
*這時候打開終端窗口芦劣,你的終端看起來就和我的一樣漂亮了~
*use it and enjoy it~