summaryrefslogtreecommitdiff
path: root/plugins/chezmoi
diff options
context:
space:
mode:
authorAlexander Schaber <alexander@schaber.info>2024-09-27 13:58:56 +0200
committerGitHub <noreply@github.com>2024-09-27 13:58:56 +0200
commita72a26406ad3aa9a47c3f5227291bad23494bed0 (patch)
tree11f7a4b963b84764ca5f7a0a37df620ea1f9761f /plugins/chezmoi
parent2a2f8ecb67674538b4b267f0796673f779f0ae5d (diff)
downloadzsh-a72a26406ad3aa9a47c3f5227291bad23494bed0.tar.gz
zsh-a72a26406ad3aa9a47c3f5227291bad23494bed0.tar.bz2
zsh-a72a26406ad3aa9a47c3f5227291bad23494bed0.zip
feat(chezmoi): add completion plugin (#12696)
Diffstat (limited to 'plugins/chezmoi')
-rw-r--r--plugins/chezmoi/README.md11
-rw-r--r--plugins/chezmoi/chezmoi.plugin.zsh14
2 files changed, 25 insertions, 0 deletions
diff --git a/plugins/chezmoi/README.md b/plugins/chezmoi/README.md
new file mode 100644
index 000000000..32aee73b2
--- /dev/null
+++ b/plugins/chezmoi/README.md
@@ -0,0 +1,11 @@
+# chezmoi Plugin
+
+## Introduction
+
+This `chezmoi` plugin sets up completion for [chezmoi](https://chezmoi.io).
+
+To use it, add `chezmoi` to the plugins array of your zshrc file:
+
+```bash
+plugins=(... chezmoi)
+```
diff --git a/plugins/chezmoi/chezmoi.plugin.zsh b/plugins/chezmoi/chezmoi.plugin.zsh
new file mode 100644
index 000000000..80e19fea1
--- /dev/null
+++ b/plugins/chezmoi/chezmoi.plugin.zsh
@@ -0,0 +1,14 @@
+# COMPLETION FUNCTION
+if (( ! $+commands[chezmoi] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `chezmoi`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_chezmoi" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _chezmoi
+ _comps[chezmoi]=_chezmoi
+fi
+
+chezmoi completion zsh >| "$ZSH_CACHE_DIR/completions/_chezmoi" &|