diff --git a/plugins/fnox/README.md b/plugins/fnox/README.md new file mode 100644 index 000000000..4f0a69369 --- /dev/null +++ b/plugins/fnox/README.md @@ -0,0 +1,15 @@ +# fnox + +Adds shell integration and completions for [fnox](https://github.com/jdx/fnox), a tool for provider-agnostic secret injection. + +## Installation + +[Install fnox](https://fnox.jdx.dev/guide/quick-start.html), then add it to your plugins in `~/.zshrc`: + +```zsh +plugins=(fnox) +``` + +## Usage + +See the [fnox documentation](https://fnox.jdx.dev/guide/shell-integration.html) for shell integration and usage. diff --git a/plugins/fnox/fnox.plugin.zsh b/plugins/fnox/fnox.plugin.zsh new file mode 100644 index 000000000..d2e924695 --- /dev/null +++ b/plugins/fnox/fnox.plugin.zsh @@ -0,0 +1,23 @@ +if (( ! $+commands[fnox] )); then + # if we don't have fnox at all just bail out + return +fi + +eval "$(fnox activate zsh)" + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `fnox`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnox" ]]; then + typeset -g -A _comps + autoload -Uz _fnox + _comps[fnox]=_fnox +fi + +# Regenerate completions when the executable changes. +if [[ ! -s "$ZSH_CACHE_DIR/completions/_fnox" || "$commands[fnox]" -nt "$ZSH_CACHE_DIR/completions/_fnox" ]]; then + zmodload -F zsh/files b:zf_mv + () { + local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnox" + zf_mv -f -- =( fnox completion zsh ) "$ZSH_CACHE_DIR/completions/_fnox" + } &| +fi