about summary refs log tree commit diff
path: root/Completion/Zsh
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-07-02 10:25:05 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-07-02 10:25:05 +0000
commit1cb11615aa337d98022a48c1c3c8c5c33b0b57c2 (patch)
tree666f075271d340fabcc63b564e1c296aa3715f9e /Completion/Zsh
parentbedc4995d225195a2e48c0d9430ceb97adfb7e2f (diff)
downloadzsh-1cb11615aa337d98022a48c1c3c8c5c33b0b57c2.tar.gz
zsh-1cb11615aa337d98022a48c1c3c8c5c33b0b57c2.tar.xz
zsh-1cb11615aa337d98022a48c1c3c8c5c33b0b57c2.zip
merge changes back from 4.1
Diffstat (limited to 'Completion/Zsh')
-rw-r--r--Completion/Zsh/Command/_compdef54
-rw-r--r--Completion/Zsh/Command/_hash40
-rw-r--r--Completion/Zsh/Command/_which39
3 files changed, 133 insertions, 0 deletions
diff --git a/Completion/Zsh/Command/_compdef b/Completion/Zsh/Command/_compdef
new file mode 100644
index 000000000..b9b590b2d
--- /dev/null
+++ b/Completion/Zsh/Command/_compdef
@@ -0,0 +1,54 @@
+#compdef compdef
+
+local state line expl list disp curcontext="$curcontext" ret=1
+typeset -A opt_args
+
+_arguments -C -s -A "-*" -S \
+  '(-d)-a[make function autoloadable]' \
+  '(-d -p -P)-n[leave existing definitions intact]' \
+  ':completion function:->cfun' \
+  '*:commands: _command_names' \
+ - d \
+  '(-a -n)-d[delete]:*:completed command:->ccom' \
+ - p \
+  '(-n)-p[completion for command matching pattern]:completion function:->cfun:pattern' \
+ - P \
+  '(-n)-P[as -p for commands without own completion]:completion function:->cfun:pattern' \
+ - k \
+  '-k[define widget and key binding]:completion function:->cfun:style:->style:*:key' \
+ - K \
+  '-K[define multiple widgets based on function]:*::: :->multi' && ret=0
+
+if [[ $state = multi ]]; then
+  case $(( CURRENT % 3 )) in
+  0) _message key
+     return 1;;
+  1) state=cfun;;
+  2) state=style;;
+  esac
+fi
+
+case $state in
+  ccom)
+    _wanted commands expl 'completed command' compadd -k _comps && ret=0
+  ;;
+  cfun)
+    list=( ${^fpath:/.}/_(|*[^~])(:t) )
+    if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
+      disp=( ${list[@]#_} )
+      _wanted functions expl 'completion function' \
+          compadd -d disp -a list && ret=0
+    else
+      _wanted functions expl 'completion function' compadd -a list && ret=0
+    fi
+  ;;
+  style)
+    _wanted widgetstyle expl 'widget style' \
+        compadd -M 'r:|-=* r:|=*' \
+            complete-word delete-char-or-list expand-or-complete \
+            expand-or-complete-prefix list-choices menu-complete \
+            menu-expand-or-complete reverse-menu-complete && ret=0
+  ;;
+esac
+
+return ret
diff --git a/Completion/Zsh/Command/_hash b/Completion/Zsh/Command/_hash
new file mode 100644
index 000000000..80c136118
--- /dev/null
+++ b/Completion/Zsh/Command/_hash
@@ -0,0 +1,40 @@
+#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
+    _wanted -C name commands expl command compadd -q -S '=' -k commands && ret=0
+  fi
+fi
+
+return ret
diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which
new file mode 100644
index 000000000..2b89112bc
--- /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: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' && ret=0
+
+fi
+
+return ret