summaryrefslogtreecommitdiff
path: root/oh-my-zsh/plugins/watson
diff options
context:
space:
mode:
authorAditya <bluenerd@protonmail.com>2023-02-27 20:04:56 +0530
committerAditya <bluenerd@protonmail.com>2023-02-27 20:04:56 +0530
commitedc449275b6c04445f58b108ca0937a87c1e8430 (patch)
tree9fd484d58145b616f29a78857cc0b1c8b1c18f05 /oh-my-zsh/plugins/watson
parent6f5424ca96c4221ef433f545642669e9c104d0ed (diff)
add zsh
Diffstat (limited to 'oh-my-zsh/plugins/watson')
-rw-r--r--oh-my-zsh/plugins/watson/README.md9
-rw-r--r--oh-my-zsh/plugins/watson/_watson34
2 files changed, 43 insertions, 0 deletions
diff --git a/oh-my-zsh/plugins/watson/README.md b/oh-my-zsh/plugins/watson/README.md
new file mode 100644
index 0000000..ef734ec
--- /dev/null
+++ b/oh-my-zsh/plugins/watson/README.md
@@ -0,0 +1,9 @@
+# Watson
+
+This plugin provides completion for [Watson](https://tailordev.github.io/Watson/).
+
+To use it add `watson` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... watson)
+```
diff --git a/oh-my-zsh/plugins/watson/_watson b/oh-my-zsh/plugins/watson/_watson
new file mode 100644
index 0000000..0f599bd
--- /dev/null
+++ b/oh-my-zsh/plugins/watson/_watson
@@ -0,0 +1,34 @@
+#compdef watson
+
+_watson_completion() {
+ local -a completions
+ local -a completions_with_descriptions
+ local -a response
+ (( ! $+commands[watson] )) && return 1
+
+ response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _WATSON_COMPLETE=zsh_complete watson)}")
+
+ for type key descr in ${response}; do
+ if [[ "$type" == "plain" ]]; then
+ if [[ "$descr" == "_" ]]; then
+ completions+=("$key")
+ else
+ completions_with_descriptions+=("$key":"$descr")
+ fi
+ elif [[ "$type" == "dir" ]]; then
+ _path_files -/
+ elif [[ "$type" == "file" ]]; then
+ _path_files -f
+ fi
+ done
+
+ if [ -n "$completions_with_descriptions" ]; then
+ _describe -V unsorted completions_with_descriptions -U
+ fi
+
+ if [ -n "$completions" ]; then
+ compadd -U -V unsorted -a completions
+ fi
+}
+
+compdef _watson_completion watson;