请稍侯

oh my zsh 两个常用插件

23 December 2023

Oh My Zsh 两个常用插件通用的安装方法

两个常用的插件

1.zsh-autosuggestions.

作用是根据历史输入命令的记录即时的提示(建议补全),然后按 → 键即可补全。

安装

git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-autosuggestions

配置启用插件

编辑 ~/.zshrc,找到 plugins=(git) 这一行,修改为:

plugins=(
    git
other plugins...
    zsh-autosuggestions
)

2.语法高亮插件

插件名称:zsh-syntax-highlighting 作用:命令错误会显示红色,直到你输入正确才会变绿色,另外路径正确会显示下划线。

安装:

git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

配置启用插件: 编辑 ~/.zshrc,以下部分添加插件的名字

plugins=(
   [plugins...] 
   zsh-syntax-highlighting
)

macOS 上 Homebrew安装

brew install zsh-autosuggestions
Brew install zsh-syntax-highlighting

 .zshrc 中添加 source命令使其生效
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh