kubectx-zshplugin
kubectx is a great tool for Kubernetes that provides a kubectx and kubens command that make it easier for you to work with multiple clusters and namespaces.
kubectx-zshplugin automatically installs them into your ZSH environment for you.
Installation
kubectx-zshplugin can be automatically loaded as a ZSH plugin by any framework that supports oh-my-zsh compatible plugins.
zgen
If you're using zgen:
- Add
zgen load unixorn/kubectx-zshpluginto your.zshrcalong with your otherzgen loadcommands. zgen reset && zgen save.zgenwill automatically clone thegitrepository the next time you start a terminal session.
Antigen
If you're using Antigen:
- Add
antigen bundle unixorn/kubectx-zshpluginto your.zshrcwhere you've listed your other plugins. - Close and reopen your terminal window to start a new session and Antigen will automatically clone and load the plugin for you. Alternatively, you can run
antigen bundle unixorn/kubectx-zshpluginin a running shell to haveantigenautomatically clone and load the new plugin immediately.
Oh-My-ZSH
If you're using oh-my-zsh:
In the terminal, change to oh-my-zsh's custom plugin directory:
cd ~/.oh-my-zsh/custom/plugins/Clone the repository into a new
kubectxdirectory:git clone --recursive https://github.com/unixorn/kubectx-zshplugin.git kubectxcd ~/.oh-my-zsh/custom/plugins/kubectx/git submodule initgit submodule updateEdit your
~/.zshrcand addkubectx– same as clone directory – to the list of plugins to enable:plugins=( ... kubectx )Then, restart your terminal application to refresh context and use the plugin. Alternatively, you can source your current shell configuration:
source ~/.zshrc