Skip to content

Instantly share code, notes, and snippets.

@vladfr
Created May 26, 2020 18:16
Show Gist options
  • Save vladfr/829ea760047e1655df986679eeac4813 to your computer and use it in GitHub Desktop.
Save vladfr/829ea760047e1655df986679eeac4813 to your computer and use it in GitHub Desktop.
kubectl shell completion
## Bash - OSX
# Get bash-completion going
$ brew install bash-completion
$ echo "[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion" >> ~/.bash_profile
# Put this in ~/.bash_profile
source <(kubectl completion bash)
alias k=kubectl
complete -F __start_kubectl k
# And reload your shell:
$ source ~/.bash_profile
## ZSH
# Put this in ~/.zshrc
autoload -Uz compinit && compinit # skip if you have oh-my-zsh
alias k=kubectl
# and run:
$ echo "[[ $commands[kubectl] ]] && source <(kubectl completion zsh)" >> ~/.zshrc
# And reload your shell
$ exec zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment