completion
or, if running Bash 4.1+
Installing bash completion on Linux ## If bash-completion is not installed on Linux, install the ‘bash-completion’ package ## via your distribution’s package manager. ## Load the kubectl completion code for bash into the current shell
source <(kubectl completion bash)
" >> $HOME/.bash_profile
Set the kubectl completion code for zsh[1] to autoload on startup
kubectl completion zsh > "${fpath[1]}/_kubectl"
Output shell completion code for the specified shell (bash or zsh). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash_profile.
Detailed instructions on how to do this are available here:
for linux: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion
for windows:
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2.