feat(k9s): add completion plugin for `k9s` (#12691)
Co-authored-by: Marc Cornellà <marc@mcornella.com>
Diff
1diff --git a/plugins/k9s/README.md b/plugins/k9s/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..275048cdb057975ac06c9e7be20e7d23b313688d
4--- /dev/null
5+++ b/plugins/k9s/README.md
6@@ -0,0 +1,9 @@
7+# k9s plugin
8+
9+This plugin adds completion support for the [k9s](https://k9scli.io).
10+
11+To use it, add `k9s` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... k9s)
15+```
16diff --git a/plugins/k9s/k9s.plugin.zsh b/plugins/k9s/k9s.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..630d4f7d33919b2b378e941f014fd6fd3c5f0e8c
19--- /dev/null
20+++ b/plugins/k9s/k9s.plugin.zsh
21@@ -0,0 +1,14 @@
22+if (( ! $+commands[k9s] )); then
23+ return
24+fi
25+
26+# If the completion file does not exist, fake it and load it
27+if [[ ! -f "$ZSH_CACHE_DIR/completions/_k9s" ]]; then
28+ typeset -g -A _comps
29+ autoload -Uz _k9s
30+ _comps[k9s]=_k9s
31+fi
32+
33+# and then generate it in the background. On first completion,
34+# the actual completion file will be loaded.
35+k9s completion zsh >| "$ZSH_CACHE_DIR/completions/_k9s" &|