about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_first4
-rw-r--r--Completion/Base/_subscript22
-rw-r--r--Completion/Base/_tilde26
3 files changed, 47 insertions, 5 deletions
diff --git a/Completion/Base/_first b/Completion/Base/_first
index d9e7ee82c..8b4da019d 100644
--- a/Completion/Base/_first
+++ b/Completion/Base/_first
@@ -40,9 +40,9 @@
 #       PREFIX="$PREFIX[1,-2]"
 #       # If a numeric prefix is given, we use it as the number of
 #       # lines (multiplied by ten below) in the history to search.
-#       if [[ NUMERIC -gt 1 ]]; then
+#       if [[ ${NUMERIC:-1} -gt 1 ]]; then
 #         max=$NUMERIC
-#         NUMERIC=1
+#         unset NUMERIC
 #       else
 #         # The default is to search the last 100 lines.
 #         max=10
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript
index abaabec8c..66d88b00c 100644
--- a/Completion/Base/_subscript
+++ b/Completion/Base/_subscript
@@ -1,7 +1,27 @@
 #compdef -subscript-
 
 if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
-  compgen -S ']' -k "( ${(kP)${compstate[parameter]}} )"
+  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} $(print -D ${(P)${compstate[parameter]}[$i]})" )
+  done
+
+  if [[ "$RBUFFER" = \]* ]]; then
+    compadd -S '' -V default -y list - "$ind[@]"
+  else
+    compadd -S ']' -V default -y list - "$ind[@]"
+  fi
 else
   _compalso -math-
 fi
diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde
index c24c65701..d03030821 100644
--- a/Completion/Base/_tilde
+++ b/Completion/Base/_tilde
@@ -7,10 +7,32 @@
 #   `(( compstate[nmatches] )) || compgen -nu -qS/'
 # below that.
 
+local c s dirs list
+
 if [[ "$SUFFIX" = */* ]]; then
   ISUFFIX="/${SUFFIX#*/}$ISUFFIX"
   SUFFIX="${SUFFIX%%/*}"
-  compgen -nu -S ''
+  s=(-S '')
 else
-  compgen -nu -qS/
+  s=(-qS/)
 fi
+
+if compset -P +; then
+  dirs="$(dirs -v)"
+  list=("${(f)dirs}")
+  [[ -o pushdminus ]] && dirs="$(awk '{ $1 = '$#list' - $1 - 1;
+  				        printf("%s\t%s\n", $1, $2); }' <<<$dirs)"
+  list=("${(@)list%	*}")
+  c=(-y '$dirs' -k "($list)")
+elif compset -P -; then
+  dirs="$(dirs -v)"
+  list=("${(f)dirs}")
+  [[ ! -o pushdminus ]] && dirs="$(awk '{ $1 = '$#list' - $1 - 1;
+					  printf("%s\t%s\n", $1, $2); }' <<<$dirs)"
+  list=("${(@)list%	*}")
+  c=(-y '$dirs' -k "($list)")
+else
+  c=(-nu)
+fi
+
+compgen "$c[@]" "$s[@]"