Linux安装zsh并配置ohmyzsh

2,071 阅读1分钟

系统版本Deepin20.5

1. 查看当前shell

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

2. 安装zsh

sudo apt install zsh
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/bin/zsh
/usr/bin/zsh

3. 切换到zsh

chsh -s /bin/zsh

4. 配置ohmysh

4.1下载zsh

git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh

4.2 备份~/.zshrc

cp ~/.zshrc ~/.zshrc.orig

4.3 复制模板中的zsh

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

4.4 可选的插件

建议安装,大大提升使用体验,代码自动补全和命令行高亮

下载插件

git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting

修改文件

vim ~/.zshrc

把插件名称加入其中

plugins=(git
        zsh-autosuggestions
        zsh-syntax-highlighting
        )