fix(kubectl): source completion instead of autoloading it
Diff
1diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
2index bf602bb7b85b89ff1a6889a17b19ee6efa95453a..6edb5975159c867d35ec2378c58561d9f0e24d6d 100644
3--- a/plugins/kubectl/kubectl.plugin.zsh
4+++ b/plugins/kubectl/kubectl.plugin.zsh
5@@ -8,15 +8,15 @@ if (( $+commands[kubectl] )); then
6 command mkdir -p "$ZSH_CACHE_DIR/completions"
7 (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
8 9- # If the completion file doesn't exist yet, we need to autoload it and
10- # bind it to `kubectl`. Otherwise, compinit will have already done that.
11+ # If the completion file does not exist, generate it and then source it
12+ # Otherwise, source it and regenerate in the background
13 if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then
14- typeset -g -A _comps
15- autoload -Uz _kubectl
16- _comps[kubectl]=_kubectl
17+ kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl"
18+ source "$ZSH_CACHE_DIR/completions/_kubectl"
19+ else
20+ source "$ZSH_CACHE_DIR/completions/_kubectl"
21+ kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &|
22 fi
23-
24- kubectl completion zsh >! "$ZSH_CACHE_DIR/completions/_kubectl" &|
25 fi
2627 # This command is used a LOT both below and in daily life