diff options
author | Marco Franssen <marco.franssen@gmail.com> | 2022-04-15 20:43:43 +0200 |
---|---|---|
committer | Carlo Sala <carlosalag@protonmail.com> | 2022-11-08 19:44:45 +0100 |
commit | 9f77cb29d7557ec6ce453a7372b053931a7d034d (patch) | |
tree | 2276e78645a6874f7199fcd0bb28ea6e0f676e5d /plugins/sigstore | |
parent | 1f30c1a079cd10030578e38f8562dc5be53d0fd3 (diff) | |
download | zsh-9f77cb29d7557ec6ce453a7372b053931a7d034d.tar.gz zsh-9f77cb29d7557ec6ce453a7372b053931a7d034d.tar.bz2 zsh-9f77cb29d7557ec6ce453a7372b053931a7d034d.zip |
feat(sigstore): add completion plugin
Closes #10862
Signed-off-by: Marco Franssen <marco.franssen@gmail.com>
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Diffstat (limited to 'plugins/sigstore')
-rw-r--r-- | plugins/sigstore/README.md | 13 | ||||
-rw-r--r-- | plugins/sigstore/sigstore.plugin.zsh | 22 |
2 files changed, 35 insertions, 0 deletions
diff --git a/plugins/sigstore/README.md b/plugins/sigstore/README.md new file mode 100644 index 000000000..00e83c8c2 --- /dev/null +++ b/plugins/sigstore/README.md @@ -0,0 +1,13 @@ +# Sigstore plugin + +This plugin sets up completion for the following [Sigstore](https://sigstore.dev/) CLI tools. + +- [Cosign](https://docs.sigstore.dev/cosign/overview) +- [Sget](https://docs.sigstore.dev/cosign/installation#alpine-linux) +- [Rekor](https://docs.sigstore.dev/rekor/overview) + +To use it, add `sigstore` to the plugins array in your zshrc file: + +```zsh +plugins=(... sigstore) +``` diff --git a/plugins/sigstore/sigstore.plugin.zsh b/plugins/sigstore/sigstore.plugin.zsh new file mode 100644 index 000000000..1f9d77c11 --- /dev/null +++ b/plugins/sigstore/sigstore.plugin.zsh @@ -0,0 +1,22 @@ +function install_autocompletion { + if (( ! $+commands[$1] )); then + return + fi + + # If the completion file doesn't exist yet, we need to autoload it and + # bind it to `$1` (cosign, sget, rekor-cli). Otherwise, compinit will + # have already done that + if [[ ! -f "$ZSH_CACHE_DIR/completions/_$1" ]]; then + autoload -Uz _$1 + typeset -g -A _comps + _comps[$1]=_$1 + fi + + $1 completion zsh >| "$ZSH_CACHE_DIR/completions/_$1" &| +} + +install_autocompletion cosign +install_autocompletion sget +install_autocompletion rekor-cli + +unfunction install_autocompletion |