diff options
Diffstat (limited to 'Completion/Builtins')
-rw-r--r-- | Completion/Builtins/_vars | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Completion/Builtins/_vars b/Completion/Builtins/_vars new file mode 100644 index 000000000..43cdf5d2c --- /dev/null +++ b/Completion/Builtins/_vars @@ -0,0 +1,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 |