(1)安装
sudo apt-get install zsh
(2)设置默认shell(默认装到/bin/zsh
)
which zsh | sudo tee -a /etc/shellssudo chsh -s /bin/zsh
二.配置(通过oh my zsh)
1.安装 oh my zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2.同步环境变量
source ~/.bashrc
原因:安装zsh后之前配置的环境变量和别名等都在~/.bashrc中,而现在生效的是.zshrc
3.安装插件(安装需要的就可以了)
3.1 语法高亮插件zsh-syntax-highlighting :输入的命令中间有错的时候会自动显示红色
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
3.2 自动补全插件 zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
3.3 自动跳转插件 autojump
git clone git://github.com/joelthelion/autojump.git cd autojump ./install.py # 根据安装完成后的提示,在~/.zshrc最后添加下面语句: vim ~/.zshrc [[ -s /home/misfit/.autojump/etc/profile.d/autojump.sh ]] && source /home/misfit/.autojump/etc/profile.d/autojump.sh
4.启用插件
# 编辑~/.zshrc vim ~/.zshrc # 找到plugins后括号里添加安装的插件名字 plugins=( git autojump zsh-autosuggestions zsh-syntax-highlighting ) # 最后刷新 source ~/.zshrc