1999-11-14 20:57:24 +01:00
|
|
|
#compdef getopts read unset vared
|
|
|
|
|
|
|
|
# This will handle completion of keys of associative arrays, e.g. at
|
1999-11-15 13:01:46 +01:00
|
|
|
# `vared foo[<TAB>'. However, in this version the [ must be added
|
|
|
|
# by hand.
|
1999-11-14 20:57:24 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2000-03-23 05:19:26 +01:00
|
|
|
_wanted -C subscript association-keys expl 'association key' \
|
|
|
|
compadd $addclose - ${(kP)var}
|
1999-11-14 20:57:24 +01:00
|
|
|
fi
|
|
|
|
else
|
2000-03-23 05:19:26 +01:00
|
|
|
_wanted parameters && _parameters
|
1999-11-14 20:57:24 +01:00
|
|
|
fi
|