2018年更新:git
使用過程當中發現 agnoster 這個主題雖然美觀,可是在實際使用過程當中對用戶來講並非很友好,我的來講 ys 主題更適合我。github
更改主題:vim
1
|
ZSH_THEME=
"ys"
|
最近重裝了系統,因而便從新配置了一下終端,使其更符合用戶習慣。ruby
效果以下:bash
擁有語法高亮,命令行tab補全,自動提示符,顯示Git倉庫狀態等功能。curl
安裝ide
首先咱們下載的 iTem2 這個軟件,比Mac自帶的終端更增強大。直接官網 http://iterm2.com/ 下載並安裝便可。工具
配置字體
將iTem2設置爲默認終端:url
(菜單欄)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)"
|