summary refs log tree commit diff stats
path: root/user/zsh
diff options
context:
space:
mode:
authorAlan Pearce2019-11-08 14:14:35 +0100
committerAlan Pearce2019-11-08 14:14:35 +0100
commit8adfb2610251f29a2bdec0130df74200f78dafd8 (patch)
treed16c8e0e9fe000c2d65106d17bc565d562ac109f /user/zsh
parent24d7815bbc7b0db90eb26d5d8e22dd84bc62c349 (diff)
downloadnixfiles-8adfb2610251f29a2bdec0130df74200f78dafd8.tar.lz
nixfiles-8adfb2610251f29a2bdec0130df74200f78dafd8.tar.zst
nixfiles-8adfb2610251f29a2bdec0130df74200f78dafd8.zip
zsh: update kubectl prompt setup
Diffstat (limited to 'user/zsh')
-rw-r--r--user/zsh/.config/zsh/.zshrc23
1 files changed, 8 insertions, 15 deletions
diff --git a/user/zsh/.config/zsh/.zshrc b/user/zsh/.config/zsh/.zshrc
index 23219e75..d2ed1807 100644
--- a/user/zsh/.config/zsh/.zshrc
+++ b/user/zsh/.config/zsh/.zshrc
@@ -87,29 +87,22 @@ else
   AGKOZAK_LEFT_PROMPT_ONLY=${+SSH_CLIENT}
 
   check_kubectl_context () {
-    if [[ "$PWD" =~ /kubernetes ]]
+    if [[ "$PWD" =~ /kubernetes || "$PWD" =~ /monorepo ]]
     then
-      git_branch=$(git rev-parse --abbrev-ref HEAD | tr '[:upper:]' '[:lower:]')
       kubectl_context=$(kubectl config current-context)
       kubectl_namespace=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"${kubectl_context}\")].context.namespace}")
-      case $git_branch in
-        staging)
-          kubectl_release=satoshipay-${kubectl_namespace}-staging
-          ;;
-        production)
-          kubectl_release=satoshipay-${kubectl_namespace}
-          ;;
-        master)
-          kubectl_release=
-          ;;
-        *)
-          kubectl_release=story-${git_branch}-${kubectl_namespace}
-      esac
       if [[ $kubectl_context =~ production ]]
       then
         kubectl_colour=red
+        kubectl_release=satoshipay-${kubectl_namespace}
       else
         kubectl_colour=yellow
+        if [[ -z $mr ]]
+        then
+          kubectl_release=satoshipay-${kubectl_namespace}-staging
+        else
+          kubectl_release=story-${mr}-${kubectl_namespace}
+        fi
       fi
         prompt_context="%F{$kubectl_colour}[${kubectl_context}:${kubectl_namespace}]%f"
     else