安装 zsh
# 查看系统所有 shell
chsh -l
# 如果没有 chsh 命令
cat /etc/shells
# 如果没有 zsh 则安装
## Ubuntu
sudo apt install zsh -y
## Centos
sudo yum install zsh -y
## Mac
brew install zsh
# 设置默认 shell 为 zsh
chsh -s /bin/zsh
# 如果没有 chsh 命令,找到要改 shell 的行
vi /etc/passwd
# 如果没有 chsh 命令,编辑 .bash_profile,在末尾添加
export SHELL=/bin/zsh
exec /bin/zsh -l
# 新开一个终端确认是否完成切换
echo $SHELL
安装 oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
- 解决访问不到 Github:https://github.com/521xueweihan/GitHub520
安装插件
Linux
cd ~/.oh-my-zsh/custom/plugins
# https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# https://github.com/zsh-users/zsh-autosuggestions.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git
# autojump
## Ubuntu
sudo apt install autojump -y
## Centos
yum install autojump-zsh -y
vi ~/.zshrc
# 启用插件
plugins=(git zsh-autosuggestions zsh-syntax-highlighting autojump)
# 取消注释
HIST_STAMPS="mm/dd/yyyy"
# 停止检查更新,加到 `source $ZSH/oh-my-zsh.sh` 行之前
DISABLE_AUTO_UPDATE="true"
Mac
- 按照每条安装命令执行结束的提示启用插件
brew install autojump
brew install zsh-syntax-highlighting
brew install zsh-autosuggestions
解决中文乱码
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
自动更新插件
Mac 使用 brew 安装插件,不用设置
# <https://github.com/Pilaton/OhMyZsh-full-autoupdate>
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/Pilaton/OhMyZsh-full-autoupdate.git
vi ~/.zshrc
plugins=(... ohmyzsh-full-autoupdate)
转载文章请注明出处。