mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-07-16 08:17:20 +00:00
Add basic bash completion
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
ad4b22b8c3
commit
17b32b1f64
@ -31,11 +31,11 @@ Context "dublin" set.
|
||||
Aliased "gke_ahmetb_europe-west1-b_dublin" as "dublin".
|
||||
```
|
||||
|
||||
## Help wanted
|
||||
[**Set up `bash` completion →**](completion/README.md)
|
||||
|
||||
- [ ] bash completion
|
||||
- [ ] zsh completion
|
||||
- [ ] homebrew formula/tap
|
||||
### Help wanted
|
||||
|
||||
[ ] homebrew formula/tap
|
||||
|
||||
-----
|
||||
|
||||
|
19
completion/README.md
Normal file
19
completion/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
kubectx provides shell completion scripts to complete context names, making it
|
||||
even faster to switch between contexts easily.
|
||||
|
||||
## Bash setup
|
||||
|
||||
Copy the `kubectx.bash` file to your HOME directory:
|
||||
|
||||
cp kubectx.bash ~/.kubectx.bash
|
||||
|
||||
And source it in your `~/.bashrc` file by adding the line:
|
||||
|
||||
[ -f ~/.kubectx.bash ] && source ~/.kubectx.bash
|
||||
|
||||
Start a new shell, type `kubectx`, then hit <kbd>Tab</kbd> to see the existing
|
||||
contexts.
|
||||
|
||||
You can Add `TAB: menu-complete` to your `~/.inputrc` to cycle through the
|
||||
options with <kbd>Tab</kbd>.
|
||||
|
8
completion/kubectx.bash
Normal file
8
completion/kubectx.bash
Normal file
@ -0,0 +1,8 @@
|
||||
_kube_contexts()
|
||||
{
|
||||
local curr_arg;
|
||||
curr_arg=${COMP_WORDS[COMP_CWORD]}
|
||||
COMPREPLY=( $(compgen -W "- $(kubectl config get-contexts | awk '{print $2}' | tail -n +2)" -- $curr_arg ) );
|
||||
}
|
||||
|
||||
complete -F _kube_contexts kubectx
|
Loading…
Reference in New Issue
Block a user