iTerm2+oh-my-zsh最全配置
- 安裝前先看效果圖
-
- 一.安裝[iTem2](https://iterm2.com/)
- 二.安裝[oh-my-zsh](https://ohmyz.sh/)
- 三.安裝[Powerline](https://powerline.readthedocs.io/en/latest/installation.html)
- 四.安裝 [Meslo](https://github.com/powerline/fonts) 字型庫
- 五.安裝agnoster主題
- 六.安裝文法高亮
- 七.安裝代碼補全插件
- 八.常用指令
安裝前先看效果圖
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIyVGduV2YfNWawNCM38FdsYkRGZkRG9lcvx2bjxiNx8VZ6l2cs0DOXJGco5mYwh2MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL3QjM5ETO0IjNjRDNycDO4IGMzQTYhRmMmRmYjRWZ4QzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
一.安裝iTem2
點選标題即可下載下傳,如果沒有安裝brew,執行下面指令一鍵安裝brew并自動替換為國内鏡像源
二.安裝oh-my-zsh
可能會失敗,多執行幾遍到成功為止
三.安裝Powerline
首先需要安裝pip指令(也可自行安裝Python自帶pip),再安裝Powerline
sudo easy_install pip
pip install powerline-status
或者
brew install python3
pip3 install powerline-status
四.安裝 Meslo 字型庫
可直接複制下面代碼片執行
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
安裝完畢後,進入到iTem2配置頁面進行配置:
設定背景顔色
設定字型樣式
設定command+.全局呼出
五.安裝agnoster主題
無需安裝,直接配置即可
cd ~
vim ~/.zshrc
找到ZSH_THEME,參數改成"agnoster"
六.安裝文法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
在根目錄
.zshrc
插入(注意{your_system_name}需要替換你的系統使用者名):
source /Users/{your_system_name}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
plugins=(
git
zsh-syntax-highlighting
)
七.安裝代碼補全插件
1、
zsh-completions
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
在根目錄
.zshrc
插入:
plugins=(
git
zsh-completions
)
autoload -U compinit && compinit
2、
zsh-autosuggestions
:補全的是曆史輸入的指令,點選方向鍵->即可補全
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
在根目錄
.zshrc
插入:
plugins=(
git
zsh-autosuggestions
)
因為之前調整過背景色,這邊預設是灰色,實際效果展示不出,是以要修改配置檔案,調整自動補全的底色:
打開檔案:
vim ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
修改内容:
注意:安裝上述所有内容後,一定要執行
source ~/.zshrc
使配置生效
八.常用指令
# 檢視shell
cat /etc/shells
# 更改shell
chsh -s /bin/zsh
# 檢視目前shell
echo $SHELL
[1]參考文章位址:https://www.jianshu.com/p/246b844f4449