diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2000-05-28 19:40:22 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2000-05-28 19:40:22 +0000 |
commit | 24695d682feac4c07014e14710cc4af2eb66e029 (patch) | |
tree | 168e1967e4057600f14fbe27862a5947c96e05be /Completion/Builtins | |
parent | 47532f255ef58d9e0e5bd6c909b3a7008e35ee43 (diff) | |
download | zsh-24695d682feac4c07014e14710cc4af2eb66e029.tar.gz zsh-24695d682feac4c07014e14710cc4af2eb66e029.tar.xz zsh-24695d682feac4c07014e14710cc4af2eb66e029.zip |
use of _arguments for completion of a couple more builtins (11615)
Diffstat (limited to 'Completion/Builtins')
-rw-r--r-- | Completion/Builtins/_unhash | 18 | ||||
-rw-r--r-- | Completion/Builtins/_which | 38 |
2 files changed, 49 insertions, 7 deletions
diff --git a/Completion/Builtins/_unhash b/Completion/Builtins/_unhash index fe40c25a2..b99c00ad3 100644 --- a/Completion/Builtins/_unhash +++ b/Completion/Builtins/_unhash @@ -1,6 +1,14 @@ -#defcomp unhash +#compdef unhash -[[ -mword 1 -*d* ]] && complist -n -[[ -mword 1 -*a* ]] && complist -a -[[ -mword 1 -*f* ]] && complist -F -[[ ! -mword 1 -* ]] && complist -m +local expl state line curcontext="$curcontext" + +_arguments -C -s \ + '(-a -f *)-d[remove named directories]:*:named directory:->nameddir' \ + '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \ + '(-d -a *)-f[remove functions]:*:functions:_functions' \ + '-m[treat arguments as patterns]' \ + '*:commands:_command_names -e' && return 0 + +if [[ "$state" = nameddir ]]; then + _wanted nameddir expl 'named directory' compadd - ${(@k)nameddirs} +fi diff --git a/Completion/Builtins/_which b/Completion/Builtins/_which index 324256e3d..3dc785f0f 100644 --- a/Completion/Builtins/_which +++ b/Completion/Builtins/_which @@ -1,3 +1,37 @@ -#defcomp which whence where type +#compdef which whence where type -complist -caF +local farg aarg cargs args state line curcontext="$curcontext" + +cargs=( \ + '(-v -c)-w[print command type]' \ + '-p[always do a path search]' \ + '-m[treat the arguments as patterns]' \ + '-s[print symlink free path as well]' \ + '*:commands:->command' ) +farg='-f[output contents of functions]' +aarg='-a[print all occurences in path]' + +case ${words[1]} in + whence) + _arguments -C -s \ + '(-c -w)-v[verbose output]' \ + '(-v -w)-c[csh-like output]' \ + "${cargs[@]}" "$farg" "$aarg" && return 0 + ;; + where) _arguments -C -s "${cargs[@]}" && return 0;; + which) _arguments -C -s "${cargs[@]}" "$aarg" && return 0;; + type) _arguments -C -s "${cargs[@]}" "$aarg" "$farg" && return 0;; +esac + +if [[ "$state" = command ]]; then + + args=( "$@" ) + + _alternative -O args \ + 'commands:external command:compadd - ${(k@)commands}' \ + 'builtins:builtin command:compadd - ${(k@)builtins}' \ + 'functions:shell function:compadd - ${(k@)functions}' \ + 'aliases:alias:compadd - ${(k@)aliases}' \ + 'reserved-words:reserved word:compadd - ${(k@)reswords}' + +fi |