about summary refs log tree commit diff
path: root/Completion/Base/Utility/_set_command
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2002-03-04 08:53:41 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2002-03-04 08:53:41 +0000
commitf56ba813bb92b1d61be91cb39df620b37a5a0588 (patch)
tree6b7432b8e437bfbd92b7859e0c9e38dd11277f1d /Completion/Base/Utility/_set_command
parent10490ec499fff7b932f92a0b19c7e5343a24761d (diff)
downloadzsh-f56ba813bb92b1d61be91cb39df620b37a5a0588.tar.gz
zsh-f56ba813bb92b1d61be91cb39df620b37a5a0588.tar.xz
zsh-f56ba813bb92b1d61be91cb39df620b37a5a0588.zip
allow different sets of completion definitions selected with option -T to compdef; use this for parameter values and redirections (16755)
Diffstat (limited to 'Completion/Base/Utility/_set_command')
-rw-r--r--Completion/Base/Utility/_set_command31
1 files changed, 31 insertions, 0 deletions
diff --git a/Completion/Base/Utility/_set_command b/Completion/Base/Utility/_set_command
new file mode 100644
index 000000000..daf532686
--- /dev/null
+++ b/Completion/Base/Utility/_set_command
@@ -0,0 +1,31 @@
+#autoload
+
+# This sets the parameters _comp_command1 and _comp_command2 in the
+# calling function.
+
+local command
+
+command="$words[1]"
+
+[[ -z "$command" ]] && return
+
+if (( $+builtins[$command] + $+functions[$command] )); then
+  _comp_command1="$command"
+  curcontext="${curcontext%:*:*}:${_comp_command1}:"
+elif [[ "$command[1]" = '=' ]]; then
+  eval _comp_command2\=$command
+  _comp_command1="$command[2,-1]"
+  curcontext="${curcontext%:*:*}:${_comp_command2}:"
+elif [[ "$command" = ..#/* ]]; then
+  _comp_command1="${PWD}/$command"
+  _comp_command2="${command:t}"
+  curcontext="${curcontext%:*:*}:${_comp_command2}:"
+elif [[ "$command" = */* ]]; then
+  _comp_command1="$command"
+  _comp_command2="${command:t}"
+  curcontext="${curcontext%:*:*}:${_comp_command2}:"
+else
+  _comp_command1="$command"
+  _comp_command2="$commands[$command]"
+  curcontext="${curcontext%:*:*}:${_comp_command1}:"
+fi