2956e7820ee1dd7111084a291722c12aea01bb5c

Author
Lorenzo Bolla <lorenzo.bolla@yougov.com>
Committer
Lorenzo Bolla <lorenzo.bolla@yougov.com>
Date

Message

Fix 6843 Cache kubectl completion script to file to speed up sourcing

Diff

 1diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
 2index ec1321d8be2ad22b325e67e8cf72af730156c4bd..f4062186acca3053fc618a019b72845724d3c82a 100644
 3--- a/plugins/kubectl/kubectl.plugin.zsh
 4+++ b/plugins/kubectl/kubectl.plugin.zsh
 5@@ -2,8 +2,15 @@
 6 #
 7 # Author: https://github.com/pstadler
 8 
 9+KUBECTL_COMPLETION_FILENAME="$TMPPREFIX-kubectl-completion-zsh"
10+
11+if [[ ! -f "$KUBECTL_COMPLETION_FILENAME" ]]
12+then
13+    kubectl completion zsh > "$KUBECTL_COMPLETION_FILENAME"
14+fi
15+
16 if [ $commands[kubectl] ]; then
17-  source <(kubectl completion zsh)
18+  source "$KUBECTL_COMPLETION_FILENAME"
19 fi
20 
21 # This command is used ALOT both below and in daily life