安装bash-completion
brew install bash-completion
复制kubectl completion bash到completion目录
kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
查看要添加到.bash_prfile的语句:
brew info bash-completion
Add the following line to your ~/.bash_profile:
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
将以下内容添加到~/.bash_profile
vim ~/.bash_profile
追加
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
生效
source ~/.bash_profile
网友评论