mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-12-02 10:01:17 +01:00
Add a doc describing how to add custom suggestion strategies. This was very hard to figure out without guidance.
parent
0e9c681339
commit
cf89251fbe
1 changed files with 16 additions and 0 deletions
16
How-to-Add-Custom-Suggestion-Strategy.md
Normal file
16
How-to-Add-Custom-Suggestion-Strategy.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
## 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)
|
||||
```
|
Loading…
Reference in a new issue