kubernetes的操作命令kubectl的子命令比较多,设置了自动补全后,可以加快操作速度,减少敲击键盘的次数。kubectl Enabling shell autocompletion。
source <(kubectl completion zsh)
可以导入到.zshrc中实现自动加载:
kubectl completion zsh >> ~/.zshrc
键入-n以后,按tab,自动弹出可用的ns:
➜ admin kubectl -n
default demo-echo demo-webshell kong kube-public kube-system
yum install bash-completion
source /usr/share/bash-completion/bash_completion
echo 'source <(kubectl completion bash)' >>~/.bashrc
kubectl completion bash >/etc/bash_completion.d/kubectl
brew install bash-completion@2
export BASH_COMPLETION_COMPAT_DIR=/usr/local/etc/bash_completion.d
[[ -r /usr/local/etc/profile.d/bash_completion.sh ]] && . /usr/local/etc/profile.d/bash_completion.sh
echo 'source <(kubectl completion bash)' >>~/.bashrc
kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl