浏览代码

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

Lorenzo Bolla 7 年之前
父节点
当前提交
2956e7820e
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      plugins/kubectl/kubectl.plugin.zsh

+ 8 - 1
plugins/kubectl/kubectl.plugin.zsh

@@ -2,8 +2,15 @@
 #
 # Author: https://github.com/pstadler
 
+KUBECTL_COMPLETION_FILENAME="$TMPPREFIX-kubectl-completion-zsh"
+
+if [[ ! -f "$KUBECTL_COMPLETION_FILENAME" ]]
+then
+    kubectl completion zsh > "$KUBECTL_COMPLETION_FILENAME"
+fi
+
 if [ $commands[kubectl] ]; then
-  source <(kubectl completion zsh)
+  source "$KUBECTL_COMPLETION_FILENAME"
 fi
 
 # This command is used ALOT both below and in daily life