zsh: Show kubectl namespace when in a kubernetes folder
Alan Pearce alan@alanpearce.eu
Thu, 20 Dec 2018 14:53:59 +0100
1 files changed, 4 insertions(+), 2 deletions(-)
jump to
M zsh/.config/zsh/.zshrc → zsh/.config/zsh/.zshrc
@@ -213,12 +213,14 @@ check_kubectl_context () { if [[ "$PWD" =~ /kubernetes ]] then kubectl_context=$(kubectl config current-context) + kubectl_namespace=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"${kubectl_context}\")].context.namespace}") if [[ $kubectl_context =~ production ]] then - prompt_context="%F{red}[${kubectl_context}]%f" + kubectl_colour=red else - prompt_context="%F{yellow}[${kubectl_context}]%f" + kubectl_colour=yellow fi + prompt_context="%F{$kubectl_colour}[${kubectl_context}:${kubectl_namespace}]%f" else prompt_context= fi