d77ac9e29d6079a7ecd561417772c3218aac94b1

Author
Mark Mercado <mmercado@digitalocean.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(charm): add plugin for `charm` (#10803)

Diff

 1diff --git a/plugins/charm/README.md b/plugins/charm/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..f237dceeb656faee344e6121b532679ad9e7c816
 4--- /dev/null
 5+++ b/plugins/charm/README.md
 6@@ -0,0 +1,9 @@
 7+# Charm plugin
 8+
 9+This plugin adds completion for the [charm](https://github.com/charmbracelet/charm) CLI.
10+
11+To use it, add `charm` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... charm)
15+```
16diff --git a/plugins/charm/charm.plugin.zsh b/plugins/charm/charm.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..52361ce95b60f8e008eff09e5421416bb183957c
19--- /dev/null
20+++ b/plugins/charm/charm.plugin.zsh
21@@ -0,0 +1,14 @@
22+# Autocompletion for the Charm CLI (charm).
23+if (( ! $+commands[charm] )); then
24+  return
25+fi
26+
27+# If the completion file doesn't exist yet, we need to autoload it and
28+# bind it to `charm`. Otherwise, compinit will have already done that.
29+if [[ ! -f "$ZSH_CACHE_DIR/completions/_charm" ]]; then
30+  typeset -g -A _comps
31+  autoload -Uz _charm
32+  _comps[charm]=_charm
33+fi
34+
35+charm completion zsh >| "$ZSH_CACHE_DIR/completions/_charm" &|