zsh-autosuggestions/src/suggestion.zsh

27 lines
803 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
}
2016-03-05 10:22:19 +08:00
_zsh_autosuggest_escape_command() {
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
}
2016-03-06 12:03:14 +08:00
# Get the previously executed command
_zsh_autosuggest_prev_command() {
echo -E "${history[$((HISTCMD-1))]}"
}