From 2c08d2b8423d6fc38d4d6e3be3aaebc3522b1555 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 30 May 2024 20:21:17 +0200 Subject: [PATCH] fix(kubectl): load completion properly in functions Closes #12427 --- plugins/kubectl/kubectl.plugin.zsh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 0dd4e691a..a96e409c6 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/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