oh-my-zsh 極簡配置
阿新 • • 發佈:2022-05-09
安裝zsh(Z shell)
- linux/Mac檢視可用shell:
cat /etc/shells
- 若無zsh,則安裝
- Ubuntu:
sudo apt-get install zsh
- Mac更新zsh並安裝補全外掛:
brew install zsh zsh-completions
- Ubuntu:
- 檢視預設shell:
echo $SHELL
- 如果預設不是zsh,則切換到zsh
-
[sudo] chsh -s $(which zsh)
或者chsh -s /bin/zsh
-
安裝oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
配置zch
配置檔案位置:
~/.zshrc
修改項:
theme=?
plugins=(git)
新增外掛plugins
各外掛安裝好之後,將外掛名新增進入plugins:
如plugins=(git z zsh-autosuggestions zsh-syntax-highlighting)
z
自帶,無需安裝
zsh-autosuggestions
根據命令列歷史,自動以陰影形式顯示建議命令,並一鍵補全
- 安裝外掛:
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
- 配置一鍵補全:
在配置檔案末新增一行:bindkey ',' autosuggest-accept
zsh-syntax-highlighting
自動高亮當前命令是否有效,通常顯示紅色為無效
- 安裝外掛
git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting