kubectl命令自动补全

1.安装bash-completion工具

$ yum install bash-completion -y

否则报错:

-bash: _get_comp_words_by_ref: command not found

2.执行bash_completion

$ source /usr/share/bash-completion/bash_completion

3.加载kubectl completion

$ source <(kubectl completion bash) 
# 在 bash 中设置当前 shell 的自动补全,要先安装 bash-completion 包。
$ echo "source <(kubectl completion bash)" >> ~/.bashrc 
# 在您的 bash shell 中永久的添加自动补全
*************** 当你发现自己的才华撑不起野心时,就请安静下来学习吧!***************
原文地址:https://www.cnblogs.com/lvzhenjiang/p/15140614.html