Can I use autocompletion for kubectl in zsh?

Both bash and zsh supports scripts that completes printed command when you press <TAB>. The feature is called Programmable completion, and you can find more details about that here: zsh completion.

Fortunately, you don’t need to write your own script – kubectl provides it for zsh > 5.2. Try running this command: source <(kubectl completion zsh).

Another option is to use this tool: https://github.com/mkokho/kubemrr
(disclaimer: I’m the author). The reason it exists is because standard completion script is too slow – it might take seconds before Kubernetes cluster replies will all pod names. But kubemrr keeps the names locally, so the response comes back almost immediately.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)