zsh completion for Kubectl when installed via Google Cloud SDK

There is no completion for free when installing kubectl via the Google Cloud SDK.

So, this is how to manualy setup completion.

With only zsh

kubectl completion zsh > /usr/local/share/zsh/site-functions/_kubectl

Via Ohmyzsh

mkdir -p ~/.oh-my-zsh/custom/plugins/kubectl
kubectl completion zsh > ~/.oh-my-zsh/custom/plugins/kubectl/_kubectl

Add kubectl to plugins list in .zshrc

Then remember to re-run the kubectl completion zsh part after kubectl updates.

Header by Camille Kimberly, https://unsplash.com/photos/SKcTKYNRvHY.

Victor Häggqvist

Stockholm, Sweden https://victorhaggqvist.com