浏览代码

fix(kubectl): load completion properly in functions

Closes #12427
Carlo Sala 10 月之前
父节点
当前提交
2c08d2b842
共有 1 个文件被更改,包括 7 次插入9 次删除
  1. 7 9
      plugins/kubectl/kubectl.plugin.zsh

+ 7 - 9
plugins/kubectl/kubectl.plugin.zsh

@@ -180,13 +180,11 @@ alias kej='kubectl edit job'
 alias kdj='kubectl describe job'
 alias kdelj='kubectl delete job'
 
-# Only run if the user actually has kubectl installed
-if (( ${+_comps[kubectl]} )); then
-  function kj() { kubectl "$@" -o json | jq; }
-  function kjx() { kubectl "$@" -o json | fx; }
-  function ky() { kubectl "$@" -o yaml | yh; }
-
-  compdef kj=kubectl
-  compdef kjx=kubectl
-  compdef ky=kubectl
+function kj() { kubectl "$@" -o json | jq; }
+function kjx() { kubectl "$@" -o json | fx; }
+function ky() { kubectl "$@" -o yaml | yh; }
+if (( ${+functions[compdef]} )); then
+  compdef _kubectl kj
+  compdef _kubectl kjx
+  compdef _kubectl ky
 fi