From d77ac9e29d6079a7ecd561417772c3218aac94b1 Mon Sep 17 00:00:00 2001 From: Mark Mercado Date: Tue, 29 Mar 2022 05:45:20 -0400 Subject: [PATCH] feat(charm): add plugin for `charm` (#10803) --- plugins/charm/README.md | 9 +++++++++ plugins/charm/charm.plugin.zsh | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/charm/README.md create mode 100644 plugins/charm/charm.plugin.zsh diff --git a/plugins/charm/README.md b/plugins/charm/README.md new file mode 100644 index 000000000..f237dceeb --- /dev/null +++ b/plugins/charm/README.md @@ -0,0 +1,9 @@ +# Charm plugin + +This plugin adds completion for the [charm](https://github.com/charmbracelet/charm) CLI. + +To use it, add `charm` to the plugins array in your zshrc file: + +```zsh +plugins=(... charm) +``` diff --git a/plugins/charm/charm.plugin.zsh b/plugins/charm/charm.plugin.zsh new file mode 100644 index 000000000..52361ce95 --- /dev/null +++ b/plugins/charm/charm.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the Charm CLI (charm). +if (( ! $+commands[charm] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `charm`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_charm" ]]; then + typeset -g -A _comps + autoload -Uz _charm + _comps[charm]=_charm +fi + +charm completion zsh >| "$ZSH_CACHE_DIR/completions/_charm" &|