From cde216e2f4d84ec16f58a39927507b6eaccb4f42 Mon Sep 17 00:00:00 2001 From: Carlos Domingues <11181378+CarlosDomingues@users.noreply.github.com> Date: Mon, 29 Nov 2021 00:43:34 -0300 Subject: [PATCH 1/3] Use tee to write to /etc/bash_completion.d/kubectl --- .../tasks/tools/included/optional-kubectl-configs-bash-linux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md b/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md index 949f1922c4..f3ae91fe65 100644 --- a/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md +++ b/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md @@ -37,7 +37,7 @@ You now need to ensure that the kubectl completion script gets sourced in all yo - Add the completion script to the `/etc/bash_completion.d` directory: ```bash - kubectl completion bash >/etc/bash_completion.d/kubectl + echo -e "$(kubectl completion bash)" | sudo tee /etc/bash_completion.d/kubectl > /dev/null ``` If you have an alias for kubectl, you can extend shell completion to work with that alias: From 7efe6cb612bfba54fd7787896569ecb8f79fed34 Mon Sep 17 00:00:00 2001 From: Carlos Domingues <11181378+CarlosDomingues@users.noreply.github.com> Date: Mon, 29 Nov 2021 22:11:31 -0300 Subject: [PATCH 2/3] Remove unecessary "echo" Co-authored-by: Tim Bannister --- .../tasks/tools/included/optional-kubectl-configs-bash-linux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md b/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md index f3ae91fe65..5838c5c343 100644 --- a/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md +++ b/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md @@ -37,7 +37,7 @@ You now need to ensure that the kubectl completion script gets sourced in all yo - Add the completion script to the `/etc/bash_completion.d` directory: ```bash - echo -e "$(kubectl completion bash)" | sudo tee /etc/bash_completion.d/kubectl > /dev/null + kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null ``` If you have an alias for kubectl, you can extend shell completion to work with that alias: From 42e485b814f2807fce825581fe79fb89fb05cf2e Mon Sep 17 00:00:00 2001 From: Carlos Domingues <11181378+CarlosDomingues@users.noreply.github.com> Date: Mon, 29 Nov 2021 22:23:54 -0300 Subject: [PATCH 3/3] Use tabs and explicitly say this is for bash only --- .../optional-kubectl-configs-bash-linux.md | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md b/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md index 5838c5c343..0024ff8bbc 100644 --- a/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md +++ b/content/en/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md @@ -26,19 +26,18 @@ Reload your shell and verify that bash-completion is correctly installed by typi ### 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: -- Source the completion script in your `~/.bashrc` file: - - ```bash - echo 'source <(kubectl completion bash)' >>~/.bashrc - ``` - -- Add the completion script to the `/etc/bash_completion.d` directory: - - ```bash - kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null - ``` +{{< tabs name="kubectl_bash_autocompletion" >}} +{{{< tab name="User" codelang="bash" >}} +echo 'source <(kubectl completion bash)' >>~/.bashrc +{{< /tab >}} +{{< tab name="System" codelang="bash" >}} +kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null +{{< /tab >}}} +{{< /tabs >}} If you have an alias for kubectl, you can extend shell completion to work with that alias: