Generate completion in the background

This commit is contained in:
Marc Cornellà 2024-10-08 20:23:40 +02:00
commit 8203214664
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -1,11 +1,14 @@
if (( $+commands[k9s] )); then
# 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/_k9s" ]]; then
k9s completion zsh | tee "$ZSH_CACHE_DIR/completions/_k9s" >/dev/null
source "$ZSH_CACHE_DIR/completions/_k9s"
else
source "$ZSH_CACHE_DIR/completions/_k9s"
k9s completion zsh | tee "$ZSH_CACHE_DIR/completions/_k9s" >/dev/null &|
fi
if (( ! $+commands[k9s] )); then
return
fi
# If the completion file does not exist, fake it and load it
if [[ ! -f "$ZSH_CACHE_DIR/completions/_k9s" ]]; then
typeset -g -A _comps
autoload -Uz _k9s
_comps[k9s]=_k9s
fi
# and then generate it in the background. On first completion,
# the actual completion file will be loaded.
k9s completion zsh >| "$ZSH_CACHE_DIR/completions/_k9s" &|