Merge pull request #31402 from shuaijinchao/zh/tasks/tools/optional/kubectl

[zh] update kubectl user and system auto-completion config
This commit is contained in:
Kubernetes Prow Robot
2022-01-20 18:45:58 -08:00
committed by GitHub
@@ -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" >}}
--> echo 'source <(kubectl completion bash)' >>~/.bashrc
- 在文件 `~/.bashrc` 中导入(source)补全脚本: {{< /tab >}}
{{< tab name="系统全局" codelang="bash" >}}
```bash kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
echo 'source <(kubectl completion bash)' >>~/.bashrc {{< /tab >}}}
``` {{< /tabs >}}
<!--
- Add the completion script to the `/etc/bash_completion.d` directory:
-->
- 将补全脚本添加到目录 `/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: