zsh-autosuggestions/src/suggestion.zsh

22 lines
697 B
Bash
Raw Normal View History

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
# Delegate to the selected strategy to determine a suggestion
2016-02-06 06:14:08 +08:00
_zsh_autosuggest_suggestion() {
local prefix="$1"
local strategy_function="_zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
2016-02-06 06:14:08 +08:00
if [ -n "$functions[$strategy_function]" ]; then
echo -E "$($strategy_function "$prefix")"
fi
}
_zsh_autosuggest_escape_command_prefix() {
setopt localoptions EXTENDED_GLOB
# Escape special chars in the string (requires EXTENDED_GLOB)
echo -E "${1//(#m)[\\()\[\]|*?]/\\$MATCH}"
2016-02-06 06:14:08 +08:00
}