Linux安装ohmyzsh

1. 安装 zsh

1
apt install zsh

设置默认终端为 zsh(注意:不要使用 sudo)

1
chsh -s /bin/zsh

2. 安装 ohmyzsh

1
sh -c "$(curl -fsSL https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"
1
sh -c "$(wget -O- https://install.ohmyz.sh/)"

3. 配置主题

1
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

ZSH_THEME="powerlevel10k/powerlevel10k" 添加到 ~/.zshrc 文件中。

1
source ~/.zshrc

4. 配置插件

4.1 安装插件

  • zsh-autosuggestions 是一个命令提示插件,当你输入命令时,会自动推测你可能需要输入的命令
1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  • zsh-syntax-highlighting 是一个语法高亮插件,当你输入命令时,会高亮显示命令的各个部分
1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • zsh-completions 是一个补全插件,当你输入命令时,会自动补全命令的各个部分
1
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
  • z 是一个快速切换目录插件,当你输入命令时,会自动切换到你输入的目录

4.2 配置插件

plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions z) 添加到 ~/.zshrc 文件中。

1
plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions z)