command not found: __start_kubectl

Viewed 1487

I installed kubectl and tried enable shell autocompletion for zsh. When I'm using kubectl autocompletion works fine. Howewer when I'm trying use autocompletion with alias k then shell return me

k g...(eval):1: command not found: __start_kubectl                                                                                                                            8:45 
(eval):1: command not found: __start_kubectl
(eval):1: command not found: __start_kubectl

In my .zshrc file I have:

source <(kubectl completion zsh)
alias k=kubectl
compdef __start_kubectl k
2 Answers

add the following to the beginning of your ~/.zshrc file:

autoload -Uz compinit
compinit

then restart your terminal.

Can you try this one:

compdef _kubectl k
Related