用于zsh的高亮插件 zsh-syntax-highlighting

文章目录

简介

zsh-syntax-highlighting 插件为 shell zsh 提供语法高亮显示。当命令在 zsh 提示符下输入到交互式终端时,它可以突出显示命令。这有助于在运行命令之前检查命令,特别是捕获语法错误。

主页地址:https://github.com/zsh-users/zsh-syntax-highlighting

安装

执行下面的命令安装 zsh-syntax-highlighting:

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

或者使用 HomeBrew 安装:

brew install zsh-syntax-highlighting

配置

接着打开 ~/.zshrc 文件进行编辑。找到 plugins,我们需要把高亮插件加上:
在这里插入图片描述
请务必保证插件顺序,zsh-syntax-highlighting 必须在最后一个。

然后在文件末尾添加:

source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # 如果使用命令 brew 安装,则是添加这条命令语句

接着保存退出,然后执行下面的命令立即生效:

source ~/.zshrc

我已经安装了,但是命令语法并没有高亮显示!

猜你喜欢

转载自blog.csdn.net/liaowenxiong/article/details/121066858#comments_22265321
zsh