Files
kubectx/completion
Ahmet Alp Balkan 81cd522d7d Use bash completion for zsh completion
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2017-04-04 12:40:57 -07:00
..
2017-04-04 12:29:27 -07:00

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 Tab to see the existing contexts.

You can Add TAB: menu-complete to your ~/.inputrc to cycle through the options with Tab.

Zsh setup

zsh can leverage the bash completion scripts. Copy the kubectx.bash file to your HOME directory:

cp kubectx.bash ~/.kubectx.bash

And add the following to your .zshrc:

[ -f ~/.kubectx.bash ] && source ~/.kubectx.bash

Start a new shell, type kubectx, then hit Tab to see the existing contexts. If it does not work, modify the line above to:

[ -f ~/.kubectx.bash ] && autoload bashcompinit && bashcompinit && \
      source ~/.kubectx.bash