前言
iTerm2 是 macOS 下好用的 terminal 軟體,在 iTerm2 下安裝 oh-my-zsh 以打造個人專屬酷炫好用的 zsh command line 環境 :)
安裝 iTerm2
1 | brew tap caskroom/cask |
設定 iTerm2
設定 Terminal 顏色
1 | Preferences > Profiles > Terminal > Report Terminal Type |
設定成 xterm-256color
。
修改 color scheme
從 mbadolato/iTerm2-Color-Schemes 下載 Solarized Dark - Patched.itermcolors
,然後再從
1 | Preferences > Profiles > Colors > Color Presets... |
按 import…
將它載入,再從 Color Presets…
選定 Solarized Dark - Patched.itermcolors
作為 iTerm2 的 theme。
字型管理
1 | brew tap caskroom/fonts |
安裝 powerline font 字型
1 | brew cask install font-sourcecodepro-nerd-font |
iTerm2 設定
1 | Preferences > Profiles > Text > Change Font |
選擇 SauceCodePro Nerd Font
。
查詢其他 nerd 字型,
1 | brew cask search nerd |
安裝 zsh
1 | brew install zsh |
設為預設的 shell
1 | sudo sh -c "echo $(which zsh) >> /etc/shells" |
安裝 oh-my-zsh
1 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" |
安裝完成後會建立資料夾 ~/.oh-my-zsh
套用主題
1. 開啟 .zshrc
1 | vim ~/.zshrc |
2. 套用主題
預設風格為 ZSH_THEME="robbyrussell"
,修改如下,
1 | # 使用agnoster主題預設為robbyrussell |
3. 立即套用
1 | exec $SHELL |
安裝 powerlevel9k 主題
1. 下載 powerlevel9k
1 | git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k |
2. 套用
修改 ~/.zshrc
1 | 使用powerlevel9k主題亦可選擇使用agnoster或預設robbyrussell |
其他顯示指令可參考 Available Prompt Segments
Plugins
安裝 zsh-completions
1 | brew install zsh-completions |
修改 ~/.zshrc
1 | ... |
Rebuild .zcompdump
1 | rm -f ~/.zcompdump; compinit |
安裝 zsh-autosuggestions
1 | git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
zsh-users/zsh-autosuggestions - Fish-like autosuggestions for zsh
安裝 autojump
1 | brew install autojump |
wting/autojump - A cd command that learns - easily navigate directories from the command line
啟用 plugin
oh-my-zsh 內建的 plugin 都放在 ~/.oh-my-zsh/plugins
1 | ls ~/.oh-my-zsh/plugins |
修改 .zshrc
1 | plugins=(git autojump zsh-autosuggestions) |