Use bash completion for zsh completion

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2017-04-04 12:26:47 -07:00
parent 17b32b1f64
commit 81cd522d7d
No known key found for this signature in database
GPG Key ID: 3300B90BF29C804E
2 changed files with 31 additions and 5 deletions

View File

@ -16,7 +16,7 @@ about how `kubectl` can manage contexts better.
## Example
```
```sh
$ kubectx minikube
Switched to context "minikube".
@ -31,11 +31,11 @@ Context "dublin" set.
Aliased "gke_ahmetb_europe-west1-b_dublin" as "dublin".
```
[**Set up `bash` completion &rarr;**](completion/README.md)
[Set up `bash` and `zsh` completion &rarr;](completion/README.md)
### Help wanted
[ ] homebrew formula/tap
[ ] homebrew formula/tap that installs the script and completions
-----

View File

@ -5,11 +5,15 @@ even faster to switch between contexts easily.
Copy the `kubectx.bash` file to your HOME directory:
cp kubectx.bash ~/.kubectx.bash
```sh
cp kubectx.bash ~/.kubectx.bash
```
And source it in your `~/.bashrc` file by adding the line:
[ -f ~/.kubectx.bash ] && source ~/.kubectx.bash
```sh
[ -f ~/.kubectx.bash ] && source ~/.kubectx.bash
```
Start a new shell, type `kubectx`, then hit <kbd>Tab</kbd> to see the existing
contexts.
@ -17,3 +21,25 @@ contexts.
You can Add `TAB: menu-complete` to your `~/.inputrc` to cycle through the
options with <kbd>Tab</kbd>.
## Zsh setup
`zsh` can leverage the `bash` completion scripts. Copy the `kubectx.bash` file
to your HOME directory:
```sh
cp kubectx.bash ~/.kubectx.bash
```
And add the following to your `.zshrc`:
```sh
[ -f ~/.kubectx.bash ] && source ~/.kubectx.bash
```
Start a new shell, type `kubectx`, then hit <kbd>Tab</kbd> to see the existing
contexts. If it does not work, modify the line above to:
```sh
[ -f ~/.kubectx.bash ] && autoload bashcompinit && bashcompinit && \
source ~/.kubectx.bash
```