檢視系統目前使用的shell
echo $SHELL
檢視系統是否安裝了zsh
cat /etc/shells
安裝zsh
sudo apt-get install zsh
把zsh設為預設終端
chsh -s $(which zsh)
重新開機系統,可使用
reboot
重新開機後,檢視目前shell
echo $SHELL
安裝oh-my-zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
配置
vim ~/.zshrc
ZSH_THEME="agnoster"
source ~/.zshrc
agnoster主題終端亂碼的解決方案
git clone https://github.com/powerline/fonts
cd ~/fonts
./install.sh
然後在配置終端,依次選擇“編輯”->“配置檔案首選項”,選擇“自定義字型”,字型為“Ubuntu Mono derivative Powerline Regular”
隐藏固定的[email protected]資訊
vim ~/.zshrc
export DEFAULT_USER="你的username"
設定自動更新oh-my-zsh。
vim ~/.zshrc
DISABLE_UPDATE_PROMPT=true
安裝文法高亮插件zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
source ~/.zshrc
安裝文法曆史記錄插件zsh-autosuggestions
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
vim ~/.zshrc
plugins=(git zsh-autosuggestions)
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh #(加在zshrc檔案最後一行)
source ~/.zshrc
在文末尾加入
source ~/.oh-my-zsh/plugins/incr/incr*.zsh
然後
source ~/.zshrc
效果