completion for an alias also (#16701)
* completion for an alias also how to do bash completion for an alias also (e.g. when there is an alias k=kubectl) * rephrasing
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
8a3036f519
commit
99fccb9bbe
@@ -351,6 +351,12 @@ You now need to ensure that the kubectl completion script gets sourced in all yo
|
|||||||
```shell
|
```shell
|
||||||
kubectl completion bash >/etc/bash_completion.d/kubectl
|
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:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo 'alias k=kubectl' >>~/.bashrc
|
||||||
|
echo 'complete -F __start_kubectl k' >>~/.bashrc
|
||||||
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
bash-completion sources all completion scripts in `/etc/bash_completion.d`.
|
bash-completion sources all completion scripts in `/etc/bash_completion.d`.
|
||||||
@@ -413,6 +419,13 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
|
|||||||
kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl
|
kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- If you have an alias for kubectl, you can extend shell completion to work with that alias:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo 'alias k=kubectl' >>~/.bashrc
|
||||||
|
echo 'complete -F __start_kubectl k' >>~/.bashrc
|
||||||
|
```
|
||||||
|
|
||||||
- If you installed kubectl with Homebrew (as explained [above](#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
|
- If you installed kubectl with Homebrew (as explained [above](#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
@@ -432,6 +445,13 @@ To do so in all your shell sessions, add the following to your `~/.zshrc` file:
|
|||||||
source <(kubectl completion zsh)
|
source <(kubectl completion zsh)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you have an alias for kubectl, you can extend shell completion to work with that alias:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
echo 'alias k=kubectl' >>~/.zshrc
|
||||||
|
echo 'complete -F __start_kubectl k' >>~/.zshrc
|
||||||
|
```
|
||||||
|
|
||||||
After reloading your shell, kubectl autocompletion should be working.
|
After reloading your shell, kubectl autocompletion should be working.
|
||||||
|
|
||||||
If you get an error like `complete:13: command not found: compdef`, then add the following to the beginning of your `~/.zshrc` file:
|
If you get an error like `complete:13: command not found: compdef`, then add the following to the beginning of your `~/.zshrc` file:
|
||||||
|
|||||||
Reference in New Issue
Block a user