diff options
author | Alan Pearce | 2018-12-20 14:53:59 +0100 |
---|---|---|
committer | Alan Pearce | 2018-12-20 15:03:48 +0100 |
commit | 7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682 (patch) | |
tree | feb2382c1bf9301b08b8635607a1771be4f164c7 | |
parent | 9e804f6fde15bcd94e46910e758a91e55502a881 (diff) | |
download | nixfiles-7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682.tar.lz nixfiles-7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682.tar.zst nixfiles-7f2472e8035d8dbaa7c7d506f0d7c1fd58c30682.zip |
zsh: Show kubectl namespace when in a kubernetes folder
-rw-r--r-- | zsh/.config/zsh/.zshrc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 18f04a92..db108ef3 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 |