Mercurial > dotfiles
comparison .zfun/zsh-autosuggestions/src/strategies/default.zsh @ 467:e1ce8897030d
zsh: import df6f6f9ff41 of zsh-autosuggestions
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 03 Dec 2018 22:37:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
466:f248cf012d9a | 467:e1ce8897030d |
---|---|
1 | |
2 #--------------------------------------------------------------------# | |
3 # History Suggestion Strategy # | |
4 #--------------------------------------------------------------------# | |
5 # Suggests the most recent history item that matches the given | |
6 # prefix. | |
7 # | |
8 | |
9 _zsh_autosuggest_strategy_history() { | |
10 # Reset options to defaults and enable LOCAL_OPTIONS | |
11 emulate -L zsh | |
12 | |
13 # Enable globbing flags so that we can use (#m) | |
14 setopt EXTENDED_GLOB | |
15 | |
16 # Escape backslashes and all of the glob operators so we can use | |
17 # this string as a pattern to search the $history associative array. | |
18 # - (#m) globbing flag enables setting references for match data | |
19 # TODO: Use (b) flag when we can drop support for zsh older than v5.0.8 | |
20 local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" | |
21 | |
22 # Get the history items that match | |
23 # - (r) subscript flag makes the pattern match on values | |
24 typeset -g suggestion="${history[(r)${prefix}*]}" | |
25 } |