2016-03-02 03:45:55 +08:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Default Suggestion Strategy #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Suggests the most recent history item that matches the given
|
|
|
|
# prefix.
|
|
|
|
#
|
|
|
|
|
|
|
|
_zsh_autosuggest_strategy_default() {
|
2017-01-25 10:58:06 +08:00
|
|
|
setopt localoptions EXTENDED_GLOB
|
|
|
|
|
2017-01-25 14:04:07 +08:00
|
|
|
local prefix="${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
|
|
|
|
|
|
|
|
# Get the keys of the history items that match
|
|
|
|
local -a histkeys
|
|
|
|
histkeys=(${(k)history[(r)$prefix*]})
|
|
|
|
|
2017-01-28 06:18:26 +08:00
|
|
|
# Give back the value of the first key
|
|
|
|
suggestion="${history[$histkeys[1]]}"
|
2016-03-02 03:45:55 +08:00
|
|
|
}
|