From f63db227e3872e6be3a606c3c3db580e366db64b Mon Sep 17 00:00:00 2001 From: ReSearchITEng Date: Sat, 5 Oct 2019 14:07:39 +0300 Subject: [PATCH 1/2] completion for an alias also how to do bash completion for an alias also (e.g. when there is an alias k=kubectl) --- .../en/docs/tasks/tools/install-kubectl.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/content/en/docs/tasks/tools/install-kubectl.md b/content/en/docs/tasks/tools/install-kubectl.md index 1becfbae0d941..b6013f0a18afd 100644 --- a/content/en/docs/tasks/tools/install-kubectl.md +++ b/content/en/docs/tasks/tools/install-kubectl.md @@ -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 ``` +- Should you have an alias for kubectl, completion can can be extended to work for it as well: + + ```shell + echo 'alias k=kubectl' >>~/.bashrc + echo 'complete -F __start_kubectl k' >>~/.bashrc + ``` {{< note >}} 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 ``` +- Should you have an alias for kubectl, completion can can be extended to work for it as well: + + ```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 >}} @@ -432,6 +445,13 @@ To do so in all your shell sessions, add the following to your `~/.zshrc` file: source <(kubectl completion zsh) ``` +Should you have an alias for kubectl, completion can can be extended to work for it as well: + + ```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: From 4c198fcefe14cd18e6bfe04177a34f01c5906a90 Mon Sep 17 00:00:00 2001 From: ReSearchITEng Date: Tue, 8 Oct 2019 18:39:42 +0300 Subject: [PATCH 2/2] rephrasing --- content/en/docs/tasks/tools/install-kubectl.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/docs/tasks/tools/install-kubectl.md b/content/en/docs/tasks/tools/install-kubectl.md index b6013f0a18afd..d7548377823c2 100644 --- a/content/en/docs/tasks/tools/install-kubectl.md +++ b/content/en/docs/tasks/tools/install-kubectl.md @@ -351,7 +351,7 @@ You now need to ensure that the kubectl completion script gets sourced in all yo ```shell kubectl completion bash >/etc/bash_completion.d/kubectl ``` -- Should you have an alias for kubectl, completion can can be extended to work for it as well: +- If you have an alias for kubectl, you can extend shell completion to work with that alias: ```shell echo 'alias k=kubectl' >>~/.bashrc @@ -419,7 +419,7 @@ 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 ``` -- Should you have an alias for kubectl, completion can can be extended to work for it as well: +- If you have an alias for kubectl, you can extend shell completion to work with that alias: ```shell echo 'alias k=kubectl' >>~/.bashrc @@ -445,7 +445,7 @@ To do so in all your shell sessions, add the following to your `~/.zshrc` file: source <(kubectl completion zsh) ``` -Should you have an alias for kubectl, completion can can be extended to work for it as well: +If you have an alias for kubectl, you can extend shell completion to work with that alias: ```shell echo 'alias k=kubectl' >>~/.zshrc