2016-02-06 06:14:08 +08:00
|
|
|
|
2016-02-14 15:29:43 +08:00
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Suggestion #
|
|
|
|
#--------------------------------------------------------------------#
|
2016-02-06 06:14:08 +08:00
|
|
|
|
2016-03-02 03:45:55 +08:00
|
|
|
# Delegate to the selected strategy to determine a suggestion
|
2016-02-06 06:14:08 +08:00
|
|
|
_zsh_autosuggest_suggestion() {
|
2016-04-26 04:19:26 +08:00
|
|
|
local escaped_prefix="$(_zsh_autosuggest_escape_command "$1")"
|
2016-03-02 03:45:55 +08:00
|
|
|
local strategy_function="_zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
|
2016-02-06 06:14:08 +08:00
|
|
|
|
2016-03-02 03:45:55 +08:00
|
|
|
if [ -n "$functions[$strategy_function]" ]; then
|
2016-04-26 04:19:26 +08:00
|
|
|
echo -E "$($strategy_function "$escaped_prefix")"
|
2016-03-02 03:45:55 +08:00
|
|
|
fi
|
2016-02-24 11:11:56 +08:00
|
|
|
}
|
|
|
|
|
2016-03-05 10:22:19 +08:00
|
|
|
_zsh_autosuggest_escape_command() {
|
2016-02-24 11:11:56 +08:00
|
|
|
setopt localoptions EXTENDED_GLOB
|
|
|
|
|
|
|
|
# Escape special chars in the string (requires EXTENDED_GLOB)
|
2016-06-11 03:19:30 +08:00
|
|
|
echo -E "${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
|
2016-02-06 06:14:08 +08:00
|
|
|
}
|