Do you work a lot with kubectl? Do you switch a lot between different clusters and namespaces with kubectx? Do you sometimes forget in what cluster or namespace you currently are in? Are you tired of running the commands kubectx
or kubens
to check this?
Kube-prompt to the rescue!
Kube-prompt is used to display the current cluster and namespace directly in your shell prompt. This means you don't have to run any commands to check where you are. The information is always there for you without any additional keystrokes.
Example:
- Clone this repository
- Source kube-prompt.sh in your configuration file for your shell prompt
- Add
$(get_current_config)
to your prompt - Restart your terminal to apply the new changes
source ~/bin/kube-prompt.sh
PROMPT="%(?:%{$fg_bold[green]%}%m:%{$fg_bold[red]%}%m)"
PROMPT+=' %{$fg[yellow]%}$(get_current_config) %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}x"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"