ZSH安装及配置
安装zsh
Ubuntu
1 | sudo apt install -y zsh |
Centos
1 | sudo yum install -y zsh |
设置默认的Shell为zsh
centos7 下需要单独安装chsh
1 | sudo yum install util-linux-user |
然后设置默认Shell
1 | chsh -s /bin/zsh |
安装git
注:已经安装完成的可以略过
Ubuntu
1 | sudo apt install -y git |
Centos
1 | sudo yum install -y git |
安装 oh-my-zsh
安装curl
1 | sudo apt install -y curl |
GitHub
1 | sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" |
Gitee
1 | sh -c "$(curl -fsSL https://gitee.com/shmhlsy/oh-my-zsh-install.sh/raw/master/install.sh)" |
Oh My Zsh配置
主题,插件等相关配置都在~/.zshrc这个文件中,输入
1 | nano .zshrc |
修改ZSH_THEME=”robbyrussell”为ZSH_THEME=”random”每次打开都是随机主题,也可以固定自己喜欢的主题
1 | # If you come from bash you might have to change your $PATH. |
更新配置
1 | source .zshrc |
配置插件
还是 ~/.zshrc 文件,中间靠下有plugins这句话,这里可以看到我们目前启用的插件,在里面输入已安装的插件名,插件之间用空格间隔
1. zsh-syntax-highlighting
高亮语法,如图,输入正确语法会显示绿色,错误的会显示红色,使得我们无需运行该命令即可知道此命令语法是否正确
安装
GitHub
1 | git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting |
Gitee
1 | git clone https://gitee.com/meatball-org-cn/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting |
在 ~/.zshrc 中配置
1 | nano .zshrc |
1 | # Which plugins would you like to load? |
更新配置
1 | source .zshrc |
2. zsh-autosuggestions
自动补全,只需输入部分命令即可根据之前输入过的命令提示,按右键→即可补全
安装
GitHub
1 | git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
Gitee
1 | git clone https://gitee.com/meatball-org-cn/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
在 ~/.zshrc 中配置
1 | nano .zshrc |
1 | # Which plugins would you like to load? |
更新配置
1 | source .zshrc |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Meatball!