about summary refs log tree commit diff
path: root/Completion/Zsh/Command
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-25 00:23:37 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-25 00:23:37 +0000
commit1d77e36c393be4fa8d836104b6ff2d6bdcfad134 (patch)
treea9ed360c5678cb85a12dcc10985c597b67754f9b /Completion/Zsh/Command
parent57cc145802a781407bf70ee833d83af0cc8a484f (diff)
downloadzsh-1d77e36c393be4fa8d836104b6ff2d6bdcfad134.tar.gz
zsh-1d77e36c393be4fa8d836104b6ff2d6bdcfad134.tar.xz
zsh-1d77e36c393be4fa8d836104b6ff2d6bdcfad134.zip
Merge from HEAD of workers/2378{0,1,2,3}.
Diffstat (limited to 'Completion/Zsh/Command')
-rw-r--r--Completion/Zsh/Command/_command12
-rw-r--r--Completion/Zsh/Command/_hash41
-rw-r--r--Completion/Zsh/Command/_which39
3 files changed, 92 insertions, 0 deletions
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