Files
oh-my-zsh/plugins/operator-sdk/operator-sdk.plugin.zsh
T
Alexander Schaber 924db8c81b refactor(plugins): use cached background completion generation (#13662)
Move invoke, istioctl, kn, kompose, kops, oc, operator-sdk, please and
svcat off sourcing `<($cmd completion ...)` on every startup. The
completion script is now cached under $ZSH_CACHE_DIR/completions and
regenerated in the background, following the pattern used by the helm
plugin.

Writes go through a temp file (prefixed with a dot to keep it out of
$fpath) that is moved into place atomically with `zf_mv`, so a
half-written file is never sourced.
2026-11-27 13:23:29 -08:00

19 lines
708 B
Bash

# Autocompletion for the Operator SDK CLI (operator-sdk).
if (( ! $+commands[operator-sdk] )); then
return
fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_operator-sdk" ]]; then
operator-sdk completion zsh | tee "$ZSH_CACHE_DIR/completions/_operator-sdk" >/dev/null
source "$ZSH_CACHE_DIR/completions/_operator-sdk"
else
source "$ZSH_CACHE_DIR/completions/_operator-sdk"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._operator-sdk"
zf_mv -f -- =( operator-sdk completion zsh ) "$ZSH_CACHE_DIR/completions/_operator-sdk"
} &|
fi