mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-30 20:33:14 +01:00
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.
This commit is contained in:
1 parent
53f0790157
commit
924db8c81b
9 files changed
+151
-27
No files matched your search
@@ -1,4 +1,18 @@
|
||||
if [ $commands[istioctl] ]; then
|
||||
source <(istioctl completion zsh)
|
||||
compdef _istioctl istioctl
|
||||
# Autocompletion for the Istio CLI (istioctl).
|
||||
if (( ! $+commands[istioctl] )); 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/_istioctl" ]]; then
|
||||
istioctl completion zsh | tee "$ZSH_CACHE_DIR/completions/_istioctl" >/dev/null
|
||||
source "$ZSH_CACHE_DIR/completions/_istioctl"
|
||||
else
|
||||
source "$ZSH_CACHE_DIR/completions/_istioctl"
|
||||
zmodload -F zsh/files b:zf_mv
|
||||
() {
|
||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._istioctl"
|
||||
zf_mv -f -- =( istioctl completion zsh ) "$ZSH_CACHE_DIR/completions/_istioctl"
|
||||
} &|
|
||||
fi
|
||||
Reference in new issue
Block a user