一、前置校驗
# 一、默認已安裝 Homebrew、iTerm2
# 二、查看是否安裝了zsh,查看是否返回 /usr/bin/zsh
cat /etc/shells
# 若未安裝
brew install zsh
# iTerm2 啓動項配置
chsh -s /bin/zsh # 設置爲zsh
chsh -s /bin/bash # 設置爲bash(Mac自帶默認)
二、安裝 ob-my-zsh
# 方式一:wegt安裝
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
# 方式二:curl 安裝
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# 方式三:手動安裝
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 卸載
uninstall_oh_my_zsh zsh
# zsh配置環境變量
~/.zshrc
三、安裝 Powerline
# 一、檢測是否已經安裝,如有版本信息則已安裝
pip show powerline-status
# 二、將 powerline-status 安裝在/usr/根目錄中
pip install --user powerline-status
# 上一步若顯示沒有 pip,先安裝pip
sudo easy_install pip
四、設置字體
# 一、新建文件夾(如~/Desktop/OpenSource),文件夾下
cd ~/Desktop/OpenSource
git clone https://github.com/powerline/fonts.git --depth=1
# 二、進入腳本目錄
cd fonts
# 三、執行腳本
./install.sh
# 進入 iTerm2 -> Preferences -> Profiles -> Text -> Font -> Change Font
# 選擇Meslo LG S for Powerfine, 常規, 12
五、設置配色方案
# 直接下載tar.zip包(包含所有配色)
# 進入 iTerm2 -> Preferences -> Profiles->Color
# 選擇 Color Presets->import 選擇解壓好的目錄下schemes目錄中相應配色方案導入
六、安裝 oh-my-zsh 主題
# 下載安裝 agnoster 主題,將主題拷貝到oh my zsh的zsh中
cd ~/Desktop/OpenSource
git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
cd oh-my-zsh-agnoster-fcamblor/
./install
# 將 ZSH_THEME 值改成 agnoster,ecs 退出,:wq 保存
vi ~/.zshrc
七、安裝插件
# ======================== 高亮插件 ========================
# 在 ~ 目錄下新建文件夾 zsh-plugins(~/.zshrc 默認目錄)
cd zsh-plugins
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
vim .zshrc
# 文末添加如下配置
source ~/zsh-pludins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
cd ~/.oh-my-zsh/custom/plugins
vim .zshrc
# 文末添加如下配置
plugins=(zsh-syntax-highlighting)
# ======================== 自動補齊插件 ========================
cd zsh-plugins
http://mimosa-pudica.net/src/incr-0.2.zsh
# 將文件放到 ~/zsh-pludins/inrc下
vim .zshrc
source ~/.oh-my-zsh/plugins/incr/incr*.zsh