From 09b2eefef9e2214f24fe02889b66a58a8c4e3a2c Mon Sep 17 00:00:00 2001 From: Florian Rey Date: Mon, 14 Oct 2024 13:58:59 +0200 Subject: [PATCH] feat(sops): introduce sops plugin --- plugins/sops/README.md | 9 +++++++++ plugins/sops/sops.plugin.zsh | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 plugins/sops/README.md create mode 100644 plugins/sops/sops.plugin.zsh diff --git a/plugins/sops/README.md b/plugins/sops/README.md new file mode 100644 index 000000000..57b93d021 --- /dev/null +++ b/plugins/sops/README.md @@ -0,0 +1,9 @@ +## Sops + +This plugin adds completion for [sops](https://github.com/scaleway/scaleway-cli), the simple and flexible tool for managing secrets. + +To use it, add `sops` to the plugins array in your zshrc file: + +```zsh +plugins=(... sops) +``` diff --git a/plugins/sops/sops.plugin.zsh b/plugins/sops/sops.plugin.zsh new file mode 100644 index 000000000..5ff61743e --- /dev/null +++ b/plugins/sops/sops.plugin.zsh @@ -0,0 +1,23 @@ +# Completion +if (( ! $+commands[sops] )); then + return +fi + +_sops() { + local -a opts + local cur + cur=${words[-1]} + if [[ "$cur" == "-"* ]]; then + opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-shell-completion)}") + else + opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-shell-completion)}") + fi + + if [[ "${opts[1]}" != "" ]]; then + _describe 'values' opts + else + _files + fi +} + +compdef _sops sops