diff options
author | IsThisTheMatrix <46820823+causalityloop@users.noreply.github.com> | 2020-10-15 18:52:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-16 00:52:34 +0200 |
commit | 5b717ab3e4bfb627a936d7c04367a39867734d63 (patch) | |
tree | 07538d3849365677d686b93906ca1262bd1c177d /plugins/kubectl/kubectl.plugin.zsh | |
parent | 53cbd658f5ae6874af0d804cee6748dfba69e786 (diff) | |
download | zsh-5b717ab3e4bfb627a936d7c04367a39867734d63.tar.gz zsh-5b717ab3e4bfb627a936d7c04367a39867734d63.tar.bz2 zsh-5b717ab3e4bfb627a936d7c04367a39867734d63.zip |
kubectl: verify kubectl is installed before running compdef (#9346)
Diffstat (limited to 'plugins/kubectl/kubectl.plugin.zsh')
-rw-r--r-- | plugins/kubectl/kubectl.plugin.zsh | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 6292a0b2f..7a0c47945 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -150,19 +150,13 @@ alias kepvc='kubectl edit pvc' alias kdpvc='kubectl describe pvc' alias kdelpvc='kubectl delete pvc' -# Colored JSON output -kj() { - kubectl "$@" -o json | jq -} -compdef kj=kubectl - -kjx() { - kubectl "$@" -o json | fx -} -compdef kjx=kubectl +# Only run if the user actually has kubectl installed +if (( $+commands[kubectl] )); then + kj() { kubectl "$@" -o json | jq; } + kjx() { kubectl "$@" -o json | fx; } + ky() { kubectl "$@" -o yaml | yh; } -# Colored YAML output -ky() { - kubectl "$@" -o yaml | yh -} -compdef ky=kubectl + compdef kj=kubectl + compdef kjx=kubectl + compdef ky=kubectl +fi |