1

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

  1. Installed kubectl-cli via home brew
  2. enabled zsh plugin
  3. added the below code as well
    source <(kubectl completion zsh)
    autoload -Uz compinit
    compinit
    
Venu
  • 1,513
  • 3
  • 19
  • 37

1 Answers1

6

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/

Venu
  • 1,513
  • 3
  • 19
  • 37