# set alias and make permanent
echo 'alias k=kubectl' >> ~/.bashrc
# add bash completion for kubectl
apt update && apt install -y bash-completion
echo 'source <(kubectl completion bash)' >> ~/.bashrc
# source the bash completion script
echo 'source /usr/share/bash-completion/bash_completion' >> ~/.bashrc
# setup completion for kubectl
echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc
# source our bashrc to use within the bash shell
source ~/.bashrc
Reference:https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-kubectl-autocompletion
No comments:
Post a Comment