安装zsh
sudo apt-get install zsh
配置on-my-zsh
1、下载on-my-zsh项目
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
2、设置zsh为默认shell,并查看是否生效
chsh -s ${which zsh}
echo $SHELL
3、切换主题
vim ~/.zshrc
把
ZSH_THEME=""
修改为
ZSH_THEME="ys"
其他还可以修改的主题参考官方文档
4、添加自动补全插件
cd ~/.oh-my-zsh/plugins
mkdir incr
cd incr
wget https://mimosa-pudica.net/src/incr-0.2.zsh
sudo chmod 777 incr-0.2.zsh
修改~/.zshrc,在最后一行添加
source ~/.oh-my-zsh/plugins/incr/incr*.zsh
5、添加历史命令自动补全
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
修改~/.zshrc,激活插件
plugins=(
# other plugins...
zsh-autosuggestions
)
6、添加高亮插件,这个插件直接在输入过程中会提示你,当前命令是否正确,错误红色,正确绿色
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
修改~/.zshrc,激活插件
plugins=(
# other plugins...
zsh-syntax-highlighting
)
以上配置均在重启终端或者运行source ~/.zshrc后生效