After installing kubernetes-cli via homebrew in a mac with zsh, the kubernetes auto complete is not working completely or in full. Only the first tab works and not the second tab onwards. Example, if I type kubectl [TAB]
, it displays the sub commands for kubectl
, and now if I select a sub command and press [TAB], eg kubectl get [TAB]
, it freezes for a lot of time and nothing happens there after.
I tried the following ways
source <(kubectl completion zsh)
autoload -Uz compinit
compinit
Finally this worked after referring to https://kubernetes.io/docs/reference/kubectl/cheatsheet/#zsh
echo '[[ $commands[kubectl] ]] && source <(kubectl completion zsh)' >> ~/.zshrc # add autocomplete permanently to your zsh shell
The below did not work
https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-zsh/