Skip to content

Commit a3a6d46

Browse files
authored
Merge pull request #31402 from shuaijinchao/zh/tasks/tools/optional/kubectl
[zh] update kubectl user and system auto-completion config
2 parents f59a649 + 29c2d36 commit a3a6d46

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

content/zh/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,22 @@ Reload your shell and verify that bash-completion is correctly installed by typi
6262
-->
6363
### 启动 kubectl 自动补全功能 {#enable-kubectl-autocompletion}
6464

65+
#### Bash
66+
6567
<!--
6668
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:
6769
-->
6870
你现在需要确保一点:kubectl 补全脚本已经导入(sourced)到 shell 会话中。
69-
这里有两种验证方法:
70-
71-
<!--
72-
- Source the completion script in your `~/.bashrc` file:
73-
-->
74-
- 在文件 `~/.bashrc` 中导入(source)补全脚本:
75-
76-
```bash
77-
echo 'source <(kubectl completion bash)' >>~/.bashrc
78-
```
79-
80-
<!--
81-
- Add the completion script to the `/etc/bash_completion.d` directory:
82-
-->
83-
- 将补全脚本添加到目录 `/etc/bash_completion.d` 中:
84-
85-
```bash
86-
kubectl completion bash >/etc/bash_completion.d/kubectl
87-
```
71+
可以通过以下两种方法进行设置:
72+
73+
{{< tabs name="kubectl_bash_autocompletion" >}}
74+
{{{< tab name="当前用户" codelang="bash" >}}
75+
echo 'source <(kubectl completion bash)' >>~/.bashrc
76+
{{< /tab >}}
77+
{{< tab name="系统全局" codelang="bash" >}}
78+
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
79+
{{< /tab >}}}
80+
{{< /tabs >}}
8881

8982
<!--
9083
If you have an alias for kubectl, you can extend shell completion to work with that alias:

0 commit comments

Comments
 (0)