kubectl: verify kubectl is installed before running compdef (#9346)

This commit is contained in:
IsThisTheMatrix 2020-10-15 18:52:34 -04:00 committed by GitHub
parent 53cbd658f5
commit 5b717ab3e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}
# 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; }
compdef kj=kubectl
kjx() {
kubectl "$@" -o json | fx
}
compdef kjx=kubectl
# Colored YAML output
ky() {
kubectl "$@" -o yaml | yh
}
compdef ky=kubectl
fi