[zh] update kubectl user and system auto-completion config

This commit is contained in:
帅进超
2022-01-19 16:27:44 +08:00
parent ebceaf1343
commit 29c2d36765
@@ -62,29 +62,22 @@ Reload your shell and verify that bash-completion is correctly installed by typi
--> -->
### 启动 kubectl 自动补全功能 {#enable-kubectl-autocompletion} ### 启动 kubectl 自动补全功能 {#enable-kubectl-autocompletion}
#### Bash
<!-- <!--
You now need to ensure that the kubectl completion script gets sourced in all your shell sessions. There are two ways in which you can do this: You now need to ensure that the kubectl completion script gets sourced in all your shell sessions. There are two ways in which you can do this:
--> -->
你现在需要确保一点:kubectl 补全脚本已经导入(sourced)到 shell 会话中。 你现在需要确保一点:kubectl 补全脚本已经导入(sourced)到 shell 会话中。
这里有两种验证方法 可以通过以下两种方法进行设置
<!-- {{< tabs name="kubectl_bash_autocompletion" >}}
- Source the completion script in your `~/.bashrc` file: {{{< tab name="当前用户" codelang="bash" >}}
-->
- 在文件 `~/.bashrc` 中导入(source)补全脚本:
```bash
echo 'source <(kubectl completion bash)' >>~/.bashrc echo 'source <(kubectl completion bash)' >>~/.bashrc
``` {{< /tab >}}
{{< tab name="系统全局" codelang="bash" >}}
<!-- kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
- Add the completion script to the `/etc/bash_completion.d` directory: {{< /tab >}}}
--> {{< /tabs >}}
- 将补全脚本添加到目录 `/etc/bash_completion.d` 中:
```bash
kubectl completion bash >/etc/bash_completion.d/kubectl
```
<!-- <!--
If you have an alias for kubectl, you can extend shell completion to work with that alias: If you have an alias for kubectl, you can extend shell completion to work with that alias: