Kube Quick Tip 03: Show Current Cluster/Namspace in Your Prompt

September 15, 2018

zsh command prompt with current Kubernetes cluster and Namespace

When working with multiple Kubernetes clusters knowing which cluster and Namespace kubectl is currently configured to manipulate is pretty critical.

For the zsh users amongst us there’s a handy little plugin zsh-kubectl-prompt to add your current Kubernetes cluster and Namespace to your zsh command prompt.

Here’s how:

I use zplug to manage my zsh plugins but the project includes docs for other installation methods.

# .zshrc

source ~/.zplug/init.zsh

# Other plugins...

zplug "superbrothers/zsh-kubectl-prompt"

zplug load

autoload -U colors; colors
RPROMPT='%{$fg[blue]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}'