mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-07-06 15:11:47 +02:00
27 lines
664 B
Text
27 lines
664 B
Text
#compdef -subscript-
|
|
|
|
if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
|
|
if [[ "$RBUFFER" = \]* ]]; then
|
|
compadd -S '' - "${(@kP)${compstate[parameter]}}"
|
|
else
|
|
compadd -S ']' - "${(@kP)${compstate[parameter]}}"
|
|
fi
|
|
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
|
|
local list i j
|
|
|
|
ind=( {1..${#${(P)${compstate[parameter]}}}} )
|
|
list=()
|
|
for i in "$ind[@]"; do
|
|
[[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
|
|
list=( "$list[@]" "${(r:4:: ::):)i} ${(P)${compstate[parameter]}[$i]}
|
|
)
|
|
done
|
|
|
|
if [[ "$RBUFFER" = \]* ]]; then
|
|
compadd -S '' -y list - "$ind[@]"
|
|
else
|
|
compadd -S ']' -y list - "$ind[@]"
|
|
fi
|
|
else
|
|
_compalso -math-
|
|
fi
|