Skip to main content

Kubectl Autocomplete

Enable Kubectl Autocomplete

Bash Shell

Set up autocomplete in bash into the current shell, bash-completion package should be installed first.

source <(kubectl completion bash)

Add autocomplete permanently to your bash shell.

echo "source <(kubectl completion bash)" >> ~/.bashrc

You can also use a shorthand alias for kubectl that also works with completion:

alias k=kubectl
complete -o default -F __start_kubectl k

Zsh Shell

Set up autocomplete in zsh into the current shell

source <(kubectl completion zsh)

Add autocomplete permanently to your zsh shell

echo '[[ $commands[kubectl] ]] && source <(kubectl completion zsh)' >> ~/.zshrc