all repos — nixfiles @ 7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682

System and user configuration, managed by nix and home-manager

zsh: Show kubectl namespace when in a kubernetes folder

Alan Pearce
commit

7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682

parent

9e804f6fde15bcd94e46910e758a91e55502a881

1 file changed, 4 insertions(+), 2 deletions(-)

jump to
M zsh/.config/zsh/.zshrczsh/.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