From fd403258f9fcabde276a35a350b14c16d666d92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Cola=C3=A7o?= Date: Sun, 26 May 2024 13:52:25 +0200 Subject: [PATCH] feat(tenv): Add tenv plugin Add plugin with completions for tenv: OpenTofu, Terraform, Terragrunt and Atmos version manager, written in Go. --- plugins/tenv/README.md | 9 +++++++++ plugins/tenv/tenv.plugin.zsh | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 plugins/tenv/README.md create mode 100644 plugins/tenv/tenv.plugin.zsh diff --git a/plugins/tenv/README.md b/plugins/tenv/README.md new file mode 100644 index 000000000..c055256d1 --- /dev/null +++ b/plugins/tenv/README.md @@ -0,0 +1,9 @@ +# tenv plugin + +This plugin adds completion for [tenv](https://github.com/tofuutils/tenv), OpenTofu, Terraform, Terragrunt and Atmos version manager, written in Go. + +To use it, add `tenv` to the plugins array in your zshrc file: + +```zsh +plugins=(... tenv) +``` diff --git a/plugins/tenv/tenv.plugin.zsh b/plugins/tenv/tenv.plugin.zsh new file mode 100644 index 000000000..a66653315 --- /dev/null +++ b/plugins/tenv/tenv.plugin.zsh @@ -0,0 +1,15 @@ +# Autocompletion for tenv +if (( ! $+commands[tenv] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `tenv`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_tenv" ]]; then + typeset -g -A _comps + autoload -Uz _tenv + _comps[tenv]=_tenv +fi + +tenv completion zsh >| "$ZSH_CACHE_DIR/completions/_tenv" &| +