参考:
1.https://www.jianshu.com/p/4fde9ae77922
2.https://www.cnblogs.com/dhcn/p/11666845.html
一.安装zsh
1.源码安装
(1)安装:
wget https://sourceforge.net/projects/zsh/files/latest/download tar -xvJf zsh-5.7.1.tar.xz cd zsh-5.7.1 ./configure make sudo make install
注意:Makefile是./configure之后才有的
添加zsh到shell名单中并修改默认shell设置
(2).设置默认shell (默认装到/usr/local/bin/zsh
)
which zsh | sudo tee -a /etc/shells sudo chsh -s /usr/local/bin/zsh
logout后重新登录即可使用zsh
警告:如果重新登录不可以用需要重启,一定要确保知道root密码,不然/bin/bash进不去了就废了,知道root密码还能改回来
2.直接安装
(1)安装
sudo apt-get install zsh
(2)设置默认shell(默认装到/bin/zsh
)
which zsh | sudo tee -a /etc/shells sudo 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 # 根据安装完成后的提示,在~/.bashrc最后添加下面语句: vim ~/.bashrc [[ -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
原文地址:https://www.cnblogs.com/cxl-blog/p/12347993.html
时间: 2024-10-11 17:11:42