[TOC] ### zsh-autosuggestions ---- #### [介绍](https://github.com/zsh-users/zsh-autosuggestions#zsh-autosuggestions) 插件代码仓库:<https://github.com/zsh-users/zsh-autosuggestions> 该插件的作用:自动补全命令,当输入命令时,它会根据历史命令进行提示,并且可以快速进行补全 #### [安装](https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md) 将代码拉取到 `$ZSH_CUSTOM/plugins`,默认为【~/.oh-my-zsh/custom/plugins】 ``` git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ``` 修改配置文件【~/.zshrc】,引用插件 ``` # 修改前 plugins=(git) # 修改后 plugins=(git zsh-autosuggestions) ``` 运行以下命令使【~/.zshrc】立即生效 ```bash source ~/.zshrc ``` #### [配置](https://github.com/zsh-users/zsh-autosuggestions#configuration) 有时插件的提示颜色看不清,可以修改配置文件调整颜色  打开配置文件 `$ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh`,修改以下配置项: ``` # 默认值 typeset -g ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' ``` 使用以下命令使其立即生效(官方文档是这样的,但我测试后必须在新窗口才会生效) ```bash source ~/.zshrc ``` #### [卸载](https://github.com/zsh-users/zsh-autosuggestions#uninstallation) **第一步:删除 【~/.zshrc】中引用此插件的代码** ``` # 修改前 plugins=(git zsh-autosuggestions) # 修改后 plugins=(git) ``` 运行以下命令使【~/.zshrc】立即生效 ```bash source ~/.zshrc ``` **第二步:从硬盘中删除此插件的 git 仓库** oh my zsh 的第三方插件一般都存放在这个目录下,先进入目录看一下,确认是否在这里 ``` $ echo $ZSH_CUSTOM/plugins /Users/liang/.oh-my-zsh/custom/plugins ``` 发现 zsh-autosuggestions 仓库确实在这个目录下,放心执行删除命令即可 ``` rm -rf $ZSH_CUSTOM/plugins/zsh-autosuggestions ```  ### zsh-syntax-highlighting ---- #### 1. 介绍 插件代码仓库:<https://github.com/zsh-users/zsh-syntax-highlighting> 该插件的作用:它可以突出显示命令,有助于在运行命令之前检查命令,当命令不存在时显示红色 #### 2. 安装 将代码拉取到 `$ZSH_CUSTOM/plugins` ``` git clone git@github.com:zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ``` 修改配置文件【~/.zshrc】,引用插件,请务必保证插件引用顺序,将它放在最后一个 ``` # 修改前 plugins=(git) # 修改后 plugins=(git zsh-syntax-highlighting) ``` 使用 brew 安装 ``` brew install zsh-syntax-highlighting ``` ``` source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ``` ### you-should-use ---- you-should-use 的用途:如果执行的命令存在别名,会自动提示推荐使用别名 代码仓库:<https://github.com/MichaelAquilina/zsh-you-should-use>,常规的安装方式,进入 github 查看如何安装即可  从上图可以看出,提示信息默认是输出结果的最前面显示的 在 `~/.zshrc` 文件中增加以下内容,就可以将别名提示放于输出结果之后 ``` export YSU_MESSAGE_POSITION="after" ``` ### zsh-history-substring-search --- 它的主要作用是根据字符串从历史命令记录中匹配命令 代码仓库:<https://github.com/zsh-users/zsh-history-substring-search>,常规安装方式,进入仓库查看如何安装即可 ``` bindkey '^[[A' history-substring-search-up bindkey '^[[B' history-substring-search-down ``` 如果没有生效,在执行下面两个命令 ``` bindkey "$terminfo[kcuu1]" history-substring-search-up bindkey "$terminfo[kcud1]" history-substring-search-down ```