Skip to content

Commit 77cc385

Browse files
authored
Merge pull request #30662 from CarlosDomingues/patch-1
Use tee to write to /etc/bash_completion.d/kubectl
2 parents c4b4768 + 42e485b commit 77cc385

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,18 @@ Reload your shell and verify that bash-completion is correctly installed by typi
2626

2727
### Enable kubectl autocompletion
2828

29-
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:
30-
31-
- Source the completion script in your `~/.bashrc` file:
29+
#### Bash
3230

33-
```bash
34-
echo 'source <(kubectl completion bash)' >>~/.bashrc
35-
```
36-
37-
- Add the completion script to the `/etc/bash_completion.d` directory:
31+
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:
3832

39-
```bash
40-
kubectl completion bash >/etc/bash_completion.d/kubectl
41-
```
33+
{{< tabs name="kubectl_bash_autocompletion" >}}
34+
{{{< tab name="User" codelang="bash" >}}
35+
echo 'source <(kubectl completion bash)' >>~/.bashrc
36+
{{< /tab >}}
37+
{{< tab name="System" codelang="bash" >}}
38+
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
39+
{{< /tab >}}}
40+
{{< /tabs >}}
4241

4342
If you have an alias for kubectl, you can extend shell completion to work with that alias:
4443

0 commit comments

Comments
 (0)