安装zsh
apt install zsh
安装oh-my-zsh
# By curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# By wget
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
切换至zsh
# 安装oh-my-zsh时会有如下提示,是否设置zsh为默认shell。
Do you want to change your default shell to zsh? [Y/n] y
# 手动设置
chsh -s /bin/zsh
# 临时进入
zsh
设置.zshrc
主题
使用vim打开.zshrc,修改主题参数,主题名称参考~/.oh-my-zsh/themes/目录下的文件。
# 如果参数设置为random,每次打开shell会随机选择一个主题。
ZSH_THEME="robbyrussell"
命令自动补齐、代码高亮
进入 zsh 插件目录,并 clone 项目到此目录中。
cd "$ZSH_CUSTOM/plugins"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git
配置 .zshrc 文件。
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
让配置生效
source ~/.zshrc