Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completion for an alias also #16701

Merged
merged 2 commits into from
Oct 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions content/en/docs/tasks/tools/install-kubectl.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ You now need to ensure that the kubectl completion script gets sourced in all yo
```shell
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
ReSearchITEng marked this conversation as resolved.
Show resolved Hide resolved
echo 'complete -F __start_kubectl k' >>~/.bashrc
```

{{< note >}}
bash-completion sources all completion scripts in `/etc/bash_completion.d`.
Expand Down Expand Up @@ -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
```

- 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.

{{< note >}}
Expand All @@ -432,6 +445,13 @@ To do so in all your shell sessions, add the following to your `~/.zshrc` file:
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.

If you get an error like `complete:13: command not found: compdef`, then add the following to the beginning of your `~/.zshrc` file:
Expand Down