1f30c1a079cd10030578e38f8562dc5be53d0fd3

Author
Sandeep Tailor <s.tailor@insysion.net>
Committer
GitHub <noreply@github.com>
Date

Message

feat(hasura): add completion plugin (#11278)

Diff

 1diff --git a/plugins/hasura/README.md b/plugins/hasura/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..d7db9ed929befcaa1519944b47bdcfbf0a7e1d01
 4--- /dev/null
 5+++ b/plugins/hasura/README.md
 6@@ -0,0 +1,9 @@
 7+# Hasura plugin
 8+
 9+This plugin adds completion for [the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/index/).
10+
11+To use it, add `hasura` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... hasura)
15+```
16diff --git a/plugins/hasura/hasura.plugin.zsh b/plugins/hasura/hasura.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..18254c43b688acf6f51888312c6f9ce9491d6694
19--- /dev/null
20+++ b/plugins/hasura/hasura.plugin.zsh
21@@ -0,0 +1,13 @@
22+if (( ! $+commands[hasura] )); then
23+  return
24+fi
25+
26+# If the completion file does not exist, generate it and then source it
27+# Otherwise, source it and regenerate in the background
28+if [[ ! -f "$ZSH_CACHE_DIR/completions/_hasura" ]]; then
29+  hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null
30+  source "$ZSH_CACHE_DIR/completions/_hasura"
31+else
32+  source "$ZSH_CACHE_DIR/completions/_hasura"
33+  hasura completion zsh --file "$ZSH_CACHE_DIR/completions/_hasura" >/dev/null &|
34+fi