mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-07-17 08:41:55 +00:00
Use bash completion for zsh completion
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
17b32b1f64
commit
81cd522d7d
@ -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 →**](completion/README.md)
|
||||
[Set up `bash` and `zsh` completion →](completion/README.md)
|
||||
|
||||
### Help wanted
|
||||
|
||||
[ ] homebrew formula/tap
|
||||
[ ] homebrew formula/tap that installs the script and completions
|
||||
|
||||
-----
|
||||
|
||||
|
@ -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
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user