AndroidStudio終端顯示-iTerm2+zsh

  1. 安裝 iTerm2
  2. 修改 iTerm2 的 color scheme
  3. 安裝 powerline font
  4. 安裝 zsh
  5. 安裝 oh-my-zsh
  6. 安裝 zsh theme: powerlevel9k
  7. 設(shè)置 powerlevel9k

安裝iTerm2

brew search iterm

在搜索結(jié)果中安裝

brew cask install iterm2

安裝好以后 打開(kāi)
Preferences > Profiles > Terminal > Report Terminal Type

改為 xterm-256color,才能在 terminal 中看得到漂亮的顏色。

修改iTerm2的color scheme

打開(kāi):Preferences > Profiles > Colors > Color Presets...

里面很一些內(nèi)置的配色,也可以到iTerm2 Color Schemes中把這個(gè)git repo下載到電腦中,然后import到iTerm2中。

安裝powerline font

因?yàn)橐恍﹖heme會(huì)用到特殊的icon,所以必須選擇支持這些特殊icon的font。這些字體統(tǒng)稱(chēng)為powerline font。

安裝powerline字體指令:

git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh
rm -rf ../fonts

先執(zhí)行,才能用 homebrew 安裝字體。

brew Tap homebrew/cask-fonts

安裝

brew cask install font-sourcecodepro-nerd-font

brew 上面也有很多字型可以挑,可是使用:

brew search nerdfont
brew cask install font-hack-nerd-font

裝完后,修改 iTerm2 字體設(shè)定
Preferences > Profiles > Text > Change Font 選擇Sauce Code Powerline字體。

安裝zsh:

檢查當(dāng)前默認(rèn)的shell:

echo $0

查看機(jī)器上支持哪些shell:

cat /etc/shells

切換到zsh:

chsh -s /bin/zsh

如果沒(méi)有安裝zsh,可以執(zhí)行如下操作:

brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells" 
chsh -s $(which zsh)

iTerm2設(shè)定路徑:Preferences > Profiles > General > Command,改為

/bin/zsh

安裝oh-my-zsh:

安裝指令:

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

安裝 zsh theme powerlevel9k

安裝好oh-my-zsh以后,默認(rèn)theme為robbyrussell,多了一些git資訊,顏色也比原生bash好看多了。

不過(guò) oh-my-zsh 內(nèi)建很多 theme,在它的 github wiki 上有很多截圖可以參考。

powerlevel9k 不只是像上面的示例顯示的一些基本資訊,還可以做到很屌的事情,比如 WiFi信號(hào)強(qiáng)度、電池電力、CPU loading、system free memory 等等在 command line

powerlevel9k 安裝方式:

1.下載

powerlevel9k 不是 oh-my-zsh 內(nèi)建的 theme ,必須另外下載:

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

2. 設(shè)置主題

編輯你的 ~/.zshrc ,把 ZSH_THEME 設(shè)置為 powerlevel9k,并設(shè)置哪些東西可以顯示在 command line 上:

#字體設(shè)定 (注意,字體設(shè)定必須放在主題之前)
POWERLEVEL9K_MODE='nerdfont-complete'
#主題設(shè)定
ZSH_THEME="powerlevel9k/powerlevel9k"
# command line 左邊顯示的內(nèi)容
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir vcs virtualenv)
# command line 右邊顯示的內(nèi)容
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time)

最后執(zhí)行

exec $SHELL # 或 

vcs 為 version control system 的縮寫(xiě)

還有非常非常多東西可以用,請(qǐng)參考這個(gè)列表自己玩玩看https://github.com/bhilburn/powerlevel9k#available-prompt-segments

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容