1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-04-10 16:32:00 +00:00

refactor(plugins): use cached background completion generation

This commit is contained in:
Alexander Schaber
2026-04-02 23:43:41 +02:00
parent 9e2c1548c3
commit d6fa1686be
9 changed files with 116 additions and 28 deletions

View File

@@ -1,5 +1,14 @@
# Autocompletion for invoke. # Autocompletion for the Invoke CLI (invoke).
# if (( ! $+commands[invoke] )); then
if [ $commands[invoke] ]; then return
source <(invoke --print-completion-script=zsh)
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `invoke`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_invoke" ]]; then
typeset -g -A _comps
autoload -Uz _invoke
_comps[invoke]=_invoke
fi
invoke --print-completion-script=zsh >| "$ZSH_CACHE_DIR/completions/_invoke" &|

View File

@@ -1,4 +1,14 @@
if [ $commands[istioctl] ]; then # Autocompletion for the Istio CLI (istioctl).
source <(istioctl completion zsh) if (( ! $+commands[istioctl] )); then
compdef _istioctl istioctl return
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `istioctl`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_istioctl" ]]; then
typeset -g -A _comps
autoload -Uz _istioctl
_comps[istioctl]=_istioctl
fi
istioctl completion zsh >| "$ZSH_CACHE_DIR/completions/_istioctl" &|

View File

@@ -1,8 +1,17 @@
# Autocompletion for kn, the command line interface for knative # Autocompletion for kn, the command line interface for Knative.
# #
# Author: https://github.com/btannous # Author: https://github.com/btannous
if [ $commands[kn] ]; then if (( ! $+commands[kn] )); then
source <(kn completion zsh) return
compdef _kn kn
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `kn`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kn" ]]; then
typeset -g -A _comps
autoload -Uz _kn
_comps[kn]=_kn
fi
kn completion zsh >| "$ZSH_CACHE_DIR/completions/_kn" &|

View File

@@ -1,3 +1,14 @@
if [ $commands[kompose] ]; then # Autocompletion for the Kompose CLI (kompose).
source <(kompose completion zsh) if (( ! $+commands[kompose] )); then
return
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `kompose`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kompose" ]]; then
typeset -g -A _comps
autoload -Uz _kompose
_comps[kompose]=_kompose
fi
kompose completion zsh >| "$ZSH_CACHE_DIR/completions/_kompose" &|

View File

@@ -1,3 +1,14 @@
if [ $commands[kops] ]; then # Autocompletion for the Kubernetes Operations CLI (kops).
source <(kops completion zsh) if (( ! $+commands[kops] )); then
return
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `kops`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kops" ]]; then
typeset -g -A _comps
autoload -Uz _kops
_comps[kops]=_kops
fi
kops completion zsh >| "$ZSH_CACHE_DIR/completions/_kops" &|

View File

@@ -2,7 +2,16 @@
# #
# Author: https://github.com/kevinkirkup # Author: https://github.com/kevinkirkup
if [ $commands[oc] ]; then if (( ! $+commands[oc] )); then
source <(oc completion zsh) return
compdef _oc oc
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `oc`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_oc" ]]; then
typeset -g -A _comps
autoload -Uz _oc
_comps[oc]=_oc
fi
oc completion zsh >| "$ZSH_CACHE_DIR/completions/_oc" &|

View File

@@ -1,4 +1,14 @@
if [ $commands[operator-sdk] ]; then # Autocompletion for the Operator SDK CLI (operator-sdk).
source <(operator-sdk completion zsh) if (( ! $+commands[operator-sdk] )); then
compdef _operator-sdk operator-sdk return
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `operator-sdk`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_operator-sdk" ]]; then
typeset -g -A _comps
autoload -Uz _operator-sdk
_comps[operator-sdk]=_operator-sdk
fi
operator-sdk completion zsh >| "$ZSH_CACHE_DIR/completions/_operator-sdk" &|

View File

@@ -1,7 +1,18 @@
if (( $+commands[plz] )); then # Autocompletion for the Please build system CLI (plz).
source <(plz --completion_script) if (( ! $+commands[plz] )); then
return
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `plz`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_plz" ]]; then
typeset -g -A _comps
autoload -Uz _plz
_comps[plz]=_plz
fi
plz --completion_script >| "$ZSH_CACHE_DIR/completions/_plz" &|
alias pb='plz build' alias pb='plz build'
alias pt='plz test' alias pt='plz test'
alias pw='plz watch' alias pw='plz watch'

View File

@@ -1,6 +1,14 @@
# Autocompletion for svcat. # Autocompletion for the Service Catalog CLI (svcat).
# if (( ! $+commands[svcat] )); then
return
if [ $commands[svcat] ]; then
source <(svcat completion zsh)
fi fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `svcat`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_svcat" ]]; then
typeset -g -A _comps
autoload -Uz _svcat
_comps[svcat]=_svcat
fi
svcat completion zsh >| "$ZSH_CACHE_DIR/completions/_svcat" &|