diff --git a/pkg/kubectl/cmd/completion.go b/pkg/kubectl/cmd/completion.go index eb61a332db0..f7017daf667 100644 --- a/pkg/kubectl/cmd/completion.go +++ b/pkg/kubectl/cmd/completion.go @@ -245,7 +245,8 @@ if sed --help 2>&1 | grep -q GNU; then RWORD='\>' fi -__kubectl_bash_source <(sed \ +__kubectl_convert_bash_to_zsh() { + sed \ -e 's/declare -F/whence -w/' \ -e 's/local \([a-zA-Z0-9_]*\)=/local \1; \1=/' \ -e 's/flags+=("\(--.*\)=")/flags+=("\1"); two_word_flags+=("\1")/' \ @@ -267,7 +268,9 @@ __kubectl_bash_source <(sed \ zsh_tail := ` BASH_COMPLETION_EOF -) +} + +__kubectl_bash_source <(__kubectl_convert_bash_to_zsh) ` out.Write([]byte(zsh_tail)) return nil