about summary refs log tree commit diff
path: root/Completion/Base/_vars
blob: 43cdf5d2ce536aed701478b118c862ab0d4e3f9b (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
#compdef getopts read unset vared

# This will handle completion of keys of associative arrays, e.g. at
# `vared compconfig[<TAB>'.  However, in this version the [ must be
# added by hand.

if [[ $PREFIX = *\[* ]]; then
  local var=${PREFIX%%\[*}
  local elt="${PREFIX#*\]}${SUFFIX%\]}"
  local addclose

  compset -p $(( ${#var} + 1 ))
  if ! compset -S \]; then
    addclose=(-S ']')
  fi
  if [[ ${(tP)var} = assoc* ]]; then
    local expl

    _tags subscript association-keys || return 1

    _description expl 'association key'
    compadd "$expl[@]" $addclose - ${(kP)var}
  fi
else
  _tags any parameters || return 1

  _parameters
fi