1 How to Add Custom Suggestion Strategy
Zane McCaig edited this page 2023-05-27 18:17:26 -07:00

Adding a Custom Suggestion Strategy

  1. Add a _zsh_autosuggest_strategy_<your custom strategy name> function to your .zshrc. It must set the global variable suggestion
  2. Export the ZSH_AUTOSUGGEST_STRATEGY

Example

This example applies the history strategy first and if it fails to find a match then it applies the custom strategy

_zsh_autosuggest_strategy_custom() {
  typeset -g suggestion
  suggestion=`./my-custom-suggestion-script.sh "$1"`
}

export ZSH_AUTOSUGGEST_STRATEGY=(history custom)