跳至主要內容

Oh My Zsh 安装与配置

Haynes...大约 3 分钟Linuxbashzshshell

omz-demo
Zsh 是 Shell 的一种,它是 Bash 的升级版,提供了更多的功能,比如自动补全、语法高亮、命令别名等等。而 Oh My Zsh 是 Zsh 的一个扩展,提供了更多的主题和插件,可以让我们更加方便的使用 Zsh。

安装 Zsh

sudo apt install zsh

安装完成后,查看系统中可用的 Shell

cat /etc/shells

将 zsh 设置为系统默认 Shell

chsh -s /bin/zsh

安装 Oh My Zsh

omz-update
omz-update
curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

配置 Oh My Zsh

Oh My Zsh 的配置文件在 ~/.zshrc 中,我们可以在这个文件中修改主题、插件等配置。

vim ~/.zshrc # 编辑配置文件
# 编辑完成后,执行以下命令使配置文件生效
source ~/.zshrc # 使配置文件生效

主题

官方主题open in new window

官方主题已经集成在 Oh My Zsh 中,我们只需要在配置文件中修改 ZSH_THEME 的值即可。

ZSH_THEME="robbyrussell"

插件

官方插件open in new window

官方插件同样已经集成在 Oh My Zsh 中,我们只需要在配置文件中修改 plugins 的值即可,格式如下。

plugins=(
  git
  yarn
  npm
  emoji
  pip
)

第三方插件推荐

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
2. 下载完成后在`~/.zshrc`中添加插件
plugins=(
    # other plugins...
    zsh-autosuggestions
)
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
2. 下载完成后在 `~/.zshrc` 中添加插件
plugins=(
    # other plugins...
    zsh-autosuggestions
    zsh-syntax-highlighting
)
  • zsh-incrementalopen in new window 实时补全插件
    1. 使用wget将插件下载到本地 $ZSH_CUSTOM/plugins目录
      (默认安装目录为 ~/.oh-my-zsh/custom/plugins)
cd $ZSH_CUSTOM/plugins
mkdir incr
cd incr
wget https://mimosa-pudica.net/src/incr-0.2.zsh
source incr-0.2.zsh
2. 下载完成后在 `~/.zshrc` 中如下代码
source $ZSH_CUSTOM/plugins/incr/incr*.zsh
  • zopen in new window 文件目录跳转插件
    z 是 oh-my-zsh 自带的插件,无需额外安装,直接在配置文件中添加即可
plugins=(
    # other plugins...
    z
)

项目地址

上次编辑于:
贡献者: HaynesChen
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3