From 29c2d367659282343093dd132b09c175c2492c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=85=E8=BF=9B=E8=B6=85?= Date: Wed, 19 Jan 2022 16:27:44 +0800 Subject: [PATCH] [zh] update kubectl user and system auto-completion config --- .../optional-kubectl-configs-bash-linux.md | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/content/zh/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md b/content/zh/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md index eaee1d9176..62046d0357 100644 --- a/content/zh/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md +++ b/content/zh/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md @@ -62,29 +62,22 @@ Reload your shell and verify that bash-completion is correctly installed by typi --> ### 启动 kubectl 自动补全功能 {#enable-kubectl-autocompletion} +#### Bash + 你现在需要确保一点:kubectl 补全脚本已经导入(sourced)到 shell 会话中。 -这里有两种验证方法: +可以通过以下两种方法进行设置: - -- 在文件 `~/.bashrc` 中导入(source)补全脚本: - - ```bash - echo 'source <(kubectl completion bash)' >>~/.bashrc - ``` - - -- 将补全脚本添加到目录 `/etc/bash_completion.d` 中: - - ```bash - kubectl completion bash >/etc/bash_completion.d/kubectl - ``` +{{< tabs name="kubectl_bash_autocompletion" >}} +{{{< tab name="当前用户" codelang="bash" >}} +echo 'source <(kubectl completion bash)' >>~/.bashrc +{{< /tab >}} +{{< tab name="系统全局" codelang="bash" >}} +kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null +{{< /tab >}}} +{{< /tabs >}}