From 7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 20 Dec 2018 14:53:59 +0100 Subject: zsh: Show kubectl namespace when in a kubernetes folder --- zsh/.config/zsh/.zshrc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'zsh') diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 18f04a9..db108ef 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -213,12 +213,14 @@ else 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 -- cgit 1.4.1