summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-09-03 14:05:07 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-09-03 14:05:07 +0000
commit4284171e9e15960996e0d77d11fde1e741145c16 (patch)
treee53501fd5be2ebc92000a77c8b05472dd3601d69
parent8e359a669e064f16d9a3767a805da28af171d5e7 (diff)
downloadzsh-4284171e9e15960996e0d77d11fde1e741145c16.tar.gz
zsh-4284171e9e15960996e0d77d11fde1e741145c16.tar.xz
zsh-4284171e9e15960996e0d77d11fde1e741145c16.zip
19019: only complete aliases of the appropriate type for the alias builtin
-rw-r--r--Completion/Zsh/Command/_alias13
-rw-r--r--Completion/Zsh/Command/_unhash9
2 files changed, 13 insertions, 9 deletions
diff --git a/Completion/Zsh/Command/_alias b/Completion/Zsh/Command/_alias
index 8feb14a07..8b28f470a 100644
--- a/Completion/Zsh/Command/_alias
+++ b/Completion/Zsh/Command/_alias
@@ -1,11 +1,12 @@
 #compdef alias
 
-local curcontext="$curcontext" state line suf
+local curcontext="$curcontext" state line type suf
+typeset -A opt_args
 
 _arguments -C -s -A "-*" -S \
-  '-+g[list or define global aliases]' \
-  '-+r[list or define regular aliases]' \
-  '-+s[list or define suffix aliases]' \
+  '(-r +r -s +s)-+g[list or define global aliases]' \
+  '(-g +g -s +s)-+r[list or define regular aliases]' \
+  '(-r +r -g +g)-+s[list or define suffix aliases]' \
   '-+m[print aliases matching specified pattern]' \
   '-L[print each alias in the form of calls to alias]' \
   '*::alias definition:->defn'
@@ -16,6 +17,8 @@ if [[ -n "$state" ]]; then
     _normal
   else
     compset -S '=*' || suf='='
-    _wanted alias expl 'alias definition' _aliases -S "$suf"
+    type=( ${opt_args[(i)[-+][grs]]#?} )
+    (( $#type )) && type=( -s $type )
+    _wanted -x alias expl 'alias definition' _aliases -S "$suf" "$type[@]"
   fi
 fi
diff --git a/Completion/Zsh/Command/_unhash b/Completion/Zsh/Command/_unhash
index bf74f07c7..54c8d1669 100644
--- a/Completion/Zsh/Command/_unhash
+++ b/Completion/Zsh/Command/_unhash
@@ -3,11 +3,12 @@
 local expl state line curcontext="$curcontext"
 
 _arguments -C -s -S \
-  '(-a -f *)-d[remove named directories]:*:named directory:->nameddir' \
-  '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \
-  '(-d -a *)-f[remove functions]:*:functions:_functions' \
+  '(-a -f -s *)-d[remove named directories]:*:named directory:->nameddir' \
+  '(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \
+  '(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \
+  '(-d -a -s *)-f[remove functions]:*:function:_functions' \
   '-m[treat arguments as patterns]' \
-  '(-a -d -f -m)*:commands: _command_names -e' && return 0
+  '(-a -d -f -m)*:command: _command_names -e' && return 0
 
 [[ "$state" = nameddir ]] &&
   _wanted named-directories expl 'named directory' compadd -k nameddirs