about summary refs log tree commit diff
path: root/Completion/Builtins
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-14 19:57:24 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-14 19:57:24 +0000
commit2cb2f1741660e453573d85607260b8e9609586bf (patch)
tree3e7d46c7cf58b5983015c848dcadbf73d7e610b5 /Completion/Builtins
parent4026d75e5c00a5f03d1402743c70776ab8b8b5a5 (diff)
downloadzsh-2cb2f1741660e453573d85607260b8e9609586bf.tar.gz
zsh-2cb2f1741660e453573d85607260b8e9609586bf.tar.xz
zsh-2cb2f1741660e453573d85607260b8e9609586bf.zip
Initial revision
Diffstat (limited to 'Completion/Builtins')
-rw-r--r--Completion/Builtins/_vars28
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