1. 启用zsh
  • 修改当前用户使用的 shellzsh
root@Linux:~# echo $SHELL    ##查看当前用户的shell
/bin/bash
root@Linux:~# cat /etc/shells    ##查看当前用户的shell,由下可知需要另行安装`zsh` 
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
  • 安装zsh,同时安装oh-my-zsh扩展
  • centos: yum install zsh -y
  • debian或ubuntu:apt install zsh
  • 安装oh-my-zsh
  • 修改当前用户shellzsh
root@Linux:~# cat /etc/shells 
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/bin/zsh    ##zsh已经正确安装
root@Linux:~# chsh -s /bin/zsh    ##修改当前用户shell为zsh
Changing shell for root.
Shell not changed.
  1. 安装插件——zsh-autosuggestionszsh-syntax-highlighting
  2. 下载命令补全建议插件zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
  • 下载语法高亮插件zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
  1. 修改配置文件.zshrc
vim ~/.zshrc
  • 修改如下选项
    • 主题设置:ZSH_THEME="re5et"
    • 启用插件
plugins=(
git     ##默认启用
z    ##实现直接跳转到指定目录下,支持自动补全。语法:z 文件夹名称
zsh-autosuggestions    ##命令补全建议插件
zsh-syntax-highlighting    ##语法高亮
extract     ##语法:x 压缩文件。解压文件而不需要知道它是何种压缩格式
)
    • 配置生效,执行
source ~/.zshrc

参考文章: