a72a26406ad3aa9a47c3f5227291bad23494bed0
- Author
- Alexander Schaber <alexander@schaber.info>
- Committer
- GitHub <noreply@github.com>
- Date
Message
feat(chezmoi): add completion plugin (#12696)
Diff
1diff --git a/plugins/chezmoi/README.md b/plugins/chezmoi/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..32aee73b2d3030de964cab78aaf94f4c542e42c2
4--- /dev/null
5+++ b/plugins/chezmoi/README.md
6@@ -0,0 +1,11 @@
7+# chezmoi Plugin
8+
9+## Introduction
10+
11+This `chezmoi` plugin sets up completion for [chezmoi](https://chezmoi.io).
12+
13+To use it, add `chezmoi` to the plugins array of your zshrc file:
14+
15+```bash
16+plugins=(... chezmoi)
17+```
18diff --git a/plugins/chezmoi/chezmoi.plugin.zsh b/plugins/chezmoi/chezmoi.plugin.zsh
19new file mode 100644
20index 0000000000000000000000000000000000000000..80e19fea1aac6f7ff7d9e697d393ada3b1a9a79f
21--- /dev/null
22+++ b/plugins/chezmoi/chezmoi.plugin.zsh
23@@ -0,0 +1,14 @@
24+# COMPLETION FUNCTION
25+if (( ! $+commands[chezmoi] )); then
26+ return
27+fi
28+
29+# If the completion file doesn't exist yet, we need to autoload it and
30+# bind it to `chezmoi`. Otherwise, compinit will have already done that.
31+if [[ ! -f "$ZSH_CACHE_DIR/completions/_chezmoi" ]]; then
32+ typeset -g -A _comps
33+ autoload -Uz _chezmoi
34+ _comps[chezmoi]=_chezmoi
35+fi
36+
37+chezmoi completion zsh >| "$ZSH_CACHE_DIR/completions/_chezmoi" &|