about summary refs log tree commit diff
path: root/Completion/Core/_history
blob: 86fd9efc5fd15da1c4ec4830de50ca40e2fdca2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#autoload

# Hm, this *can* sensibly be used as a completer. But it could also be used
# as a utility function, so maybe it should be moved into another directory.
# Or maybe not. Hm.
#
#
# Complete words from the history
#
# Code taken from _history_complete_words.
#
# Available styles:
#
#   :history-words:sort -- sort matches lexically (default is to sort by age)
#   :history-words:remove-all-dups --
#                          remove /all/ duplicate matches rather than just
#                          consecutives

local opt expl h_words

if zstyle -t ":completion:${curcontext}:" remove-all-dups; then
  opt=-
else
  opt=-1
fi

if zstyle -t ":completion:${curcontext}:" sort; then
  opt="${opt}J"
else
  opt="${opt}V"
fi

# We skip the first element of historywords so the current word doesn't
# interfere with the completion
h_words=( "${(@)historywords[2,-1]}" )
_wanted "$opt" history-words expl 'history word' compadd -Q -a h_words