From 1d77e36c393be4fa8d836104b6ff2d6bdcfad134 Mon Sep 17 00:00:00 2001 From: Paul Ackersviller Date: Sun, 25 Nov 2007 00:23:37 +0000 Subject: Merge from HEAD of workers/2378{0,1,2,3}. --- Completion/Zsh/Command/_command | 12 ++++++++++++ Completion/Zsh/Command/_hash | 41 +++++++++++++++++++++++++++++++++++++++++ Completion/Zsh/Command/_which | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 Completion/Zsh/Command/_command create mode 100644 Completion/Zsh/Command/_hash create mode 100644 Completion/Zsh/Command/_which (limited to 'Completion/Zsh/Command') diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command new file mode 100644 index 000000000..72d7b6e99 --- /dev/null +++ b/Completion/Zsh/Command/_command @@ -0,0 +1,12 @@ +#compdef command + +local ret + +if [[ CURRENT -ge 3 ]]; then + compset -n 2 + _normal && ret=0 +else + _path_commands "$@" && ret=0 +fi + +return ret diff --git a/Completion/Zsh/Command/_hash b/Completion/Zsh/Command/_hash new file mode 100644 index 000000000..d4bb59d28 --- /dev/null +++ b/Completion/Zsh/Command/_hash @@ -0,0 +1,41 @@ +#compdef hash rehash + +local state line expl common_args curcontext="$curcontext" ret=1 +typeset -A opt_args + +common_args=( \ + '-d[use named directory hash table]' \ + '(-r -m -v)-f[rebuild hash table]' ) + +case ${service} in + hash) + _arguments -C -s -S \ + '(-f -m -v)-r[empty hash table]' \ + '(-f -r)-m[treat arguments as patterns]' \ + '(-f -r -m)-v[list entries as they are added]' \ + '(-f -r -v)-L[list in the form of calls to hash]' \ + "${common_args[@]}" \ + '(-d -f -r -m -v -L)*:hash:->hashval' && ret=0 + ;; + rehash) + _arguments -C -s ${common_args[@]} && return 0 + ;; +esac + +if [[ $state = hashval ]]; then + if (( $+opt_args[-d] )); then + if compset -P 1 '*='; then + _wanted -C value files expl directories _path_files -/ && ret=0 + else + _wanted -C name named-directories expl 'named directory' \ + compadd -q -S '=' -k nameddirs && ret=0 + fi + elif compset -P 1 '*='; then + _wanted -C value values expl 'executable file' _files -g '*(-*)' && ret=0 + else + curcontext="${curcontext%:*}:name" + _path_commands -q -S '=' && ret=0 + fi +fi + +return ret diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which new file mode 100644 index 000000000..07ede39fd --- /dev/null +++ b/Completion/Zsh/Command/_which @@ -0,0 +1,39 @@ +#compdef which whence where type + +local farg aarg cargs args state line curcontext="$curcontext" ret=1 + +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 occurrences in path]' + +case ${service} in + whence) + _arguments -C -s -A "-*" -S \ + '(-c -w)-v[verbose output]' \ + '(-v -w)-c[csh-like output]' \ + "${cargs[@]}" "$farg" "$aarg" && ret=0 + ;; + where) _arguments -C -s -A "-*" -S "${cargs[@]}" && ret=0;; + which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" && ret=0;; + type) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$farg" && ret=0;; +esac + +if [[ "$state" = command ]]; then + + args=( "$@" ) + + _alternative -O args \ + 'commands:external command:_path_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' && ret=0 + +fi + +return ret -- cgit 1.4.1