[TOC] ### zsh-autosuggestions ---- #### [介紹](https://github.com/zsh-users/zsh-autosuggestions#zsh-autosuggestions) 插件代碼倉庫:<https://github.com/zsh-users/zsh-autosuggestions> 該插件的作用:自動補全命令,當(dāng)輸入命令時,它會根據(jù)歷史命令進行提示,并且可以快速進行補全 #### [安裝](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) 有時插件的提示顏色看不清,可以修改配置文件調(diào)整顏色 ![](https://img.itqaq.com/art/content/0e736c49f0c6f1c70febc576f40e8a18.png) 打開配置文件 `$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 ``` 發(fā)現(xiàn) zsh-autosuggestions 倉庫確實在這個目錄下,放心執(zhí)行刪除命令即可 ``` rm -rf $ZSH_CUSTOM/plugins/zsh-autosuggestions ``` ![](https://img.itqaq.com/art/content/cbd3d49d9324a59b07e2044edb38b1a3.png) ### zsh-syntax-highlighting ---- #### 1. 介紹 插件代碼倉庫:<https://github.com/zsh-users/zsh-syntax-highlighting> 該插件的作用:它可以突出顯示命令,有助于在運行命令之前檢查命令,當(dāng)命令不存在時顯示紅色 #### 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】,引用插件,請務(wù)必保證插件引用順序,將它放在最后一個 ``` # 修改前 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 的用途:如果執(zhí)行的命令存在別名,會自動提示推薦使用別名 代碼倉庫:<https://github.com/MichaelAquilina/zsh-you-should-use>,常規(guī)的安裝方式,進入 github 查看如何安裝即可 ![](https://img.itqaq.com/art/content/f6b16e2c070c25051ba8496247bcd5c8.png) 從上圖可以看出,提示信息默認是輸出結(jié)果的最前面顯示的 在 `~/.zshrc` 文件中增加以下內(nèi)容,就可以將別名提示放于輸出結(jié)果之后 ``` export YSU_MESSAGE_POSITION="after" ``` ### zsh-history-substring-search --- 它的主要作用是根據(jù)字符串從歷史命令記錄中匹配命令 代碼倉庫:<https://github.com/zsh-users/zsh-history-substring-search>,常規(guī)安裝方式,進入倉庫查看如何安裝即可 ``` bindkey '^[[A' history-substring-search-up bindkey '^[[B' history-substring-search-down ``` 如果沒有生效,在執(zhí)行下面兩個命令 ``` bindkey "$terminfo[kcuu1]" history-substring-search-up bindkey "$terminfo[kcud1]" history-substring-search-down ```