about summary refs log tree commit diff
path: root/Completion/Builtins/_bindkey
blob: 31215a57635d7aaf8b1b87b33cfacdd942dcbafb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#compdef bindkey

# Normally, this completes names of zle widgets, whether the builtin ones
# or ones defined by the user.  Note that a - allows a wildcard before it,
# so h-b-s-b will complete to history-beginning-search-backward.  You
# can alter this by removing the -M ... from the second compadd.
#
# Where appropriate, will complete keymaps instead of widgets.

local expl

if [[ "$words[2]" = -*[DAN]* || "$words[CURRENT-1]" = -*M ]]; then
  _tags -M keymaps || return 1

  _description expl keymap
  compadd "$expl[@]" - "$keymaps[@]"
else
  _tags any:argument widgets || return 1

  _description expl widget
  compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)widgets}"
fi