summary refs log tree commit diff stats
path: root/zsh
diff options
context:
space:
mode:
authorAlan Pearce2018-12-19 11:47:21 +0100
committerAlan Pearce2018-12-19 11:47:21 +0100
commit958131271a6f82f1d6cf22cdbb6ad6742d34d4c8 (patch)
treed341e276da3586e276c9ca77cc79b063128a2521 /zsh
parentbce46573aedafe5a484b5bf3d54dea1f18c53204 (diff)
downloaddotfiles-958131271a6f82f1d6cf22cdbb6ad6742d34d4c8.tar.lz
dotfiles-958131271a6f82f1d6cf22cdbb6ad6742d34d4c8.tar.zst
dotfiles-958131271a6f82f1d6cf22cdbb6ad6742d34d4c8.zip
zsh: Add kube context to prompt
Diffstat (limited to 'zsh')
-rw-r--r--zsh/.config/zsh/.zshrc16
1 files changed, 16 insertions, 0 deletions
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc
index 5265d1f..6effdeb 100644
--- a/zsh/.config/zsh/.zshrc
+++ b/zsh/.config/zsh/.zshrc
@@ -207,6 +207,22 @@ then
 else
   AGKOZAK_PROMPT_DIRTRIM=0
 
+  check_kubectl_context () {
+    if [[ "$PWD" =~ /kubernetes ]]
+    then
+      kubectl_context=$(kubectl config current-context)
+      if [[ $kubectl_context =~ production ]]
+      then
+        prompt_context="%F{red}[${kubectl_context}]%f"
+      else
+        prompt_context="%F{yellow}[${kubectl_context}]%f"
+      fi
+    else
+      prompt_context=
+    fi
+  }
+  precmd_functions+=(check_kubectl_context)
+  AGKOZAK_CUSTOM_RPROMPT='${prompt_context}%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}%3v%f.)'
 fi
 
 if [[ -n $commands[fzf] ]]