Add zsh-autosuggestion
[zsh.git] / .zsh / external / zsh-autosuggestions / src / suggestion.zsh
1
2 #--------------------------------------------------------------------#
3 # Suggestion #
4 #--------------------------------------------------------------------#
5
6 # Delegate to the selected strategy to determine a suggestion
7 _zsh_autosuggest_suggestion() {
8 local escaped_prefix="$(_zsh_autosuggest_escape_command "$1")"
9 local strategy_function="_zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
10
11 if [ -n "$functions[$strategy_function]" ]; then
12 echo -E "$($strategy_function "$escaped_prefix")"
13 fi
14 }
15
16 _zsh_autosuggest_escape_command() {
17 setopt localoptions EXTENDED_GLOB
18
19 # Escape special chars in the string (requires EXTENDED_GLOB)
20 echo -E "${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
21 }