zsh-autosuggestions/src/strategies/default.zsh

21 lines
603 B
Bash
Raw Normal View History

#--------------------------------------------------------------------#
# Default Suggestion Strategy #
#--------------------------------------------------------------------#
# Suggests the most recent history item that matches the given
# prefix.
#
_zsh_autosuggest_strategy_default() {
setopt localoptions EXTENDED_GLOB
local prefix="${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
# Get the keys of the history items that match
local -a histkeys
histkeys=(${(k)history[(r)$prefix*]})
2017-01-27 23:18:26 +01:00
# Give back the value of the first key
suggestion="${history[$histkeys[1]]}"
}