启用 shell 自动补全
Kubebuilder 完成脚本可以使用命令 kubebuilder completion [bash|fish|powershell|zsh] 生成。请注意,在您的 shell 中加载完成脚本可以启用 Kubebuilder 自动完成功能。
Bash
-
检查 bash 是否为可用 shell:
cat /etc/shells | grep '^.*/bash' -
如果没有,将 bash 添加到
/etc/shells。例如,若 bash 位于/usr/local/bin/bash:echo "/usr/local/bin/bash" >> /etc/shells -
确保当前用户使用 bash 作为 shell。
chsh -s /usr/local/bin/bash -
将以下内容添加到/.bash_profile或~/.bashrc中。
# kubebuilder autocompletion if [ -f /usr/local/share/bash-completion/bash_completion ]; then . /usr/local/share/bash-completion/bash_completion fi . <(kubebuilder completion bash) -
重新启动终端以使更改生效,或者使用
source命令加载更改的 bash 文件。. ~/.bash_profile
Zsh
遵循类似的协议进行 zsh 完成。
Fish
source (kubebuilder completion fish | psub)