all repos — nixfiles @ 8adfb2610251f29a2bdec0130df74200f78dafd8

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

zsh: update kubectl prompt setup
Alan Pearce alan@alanpearce.eu
Fri, 08 Nov 2019 14:14:35 +0100
commit

8adfb2610251f29a2bdec0130df74200f78dafd8

parent

24d7815bbc7b0db90eb26d5d8e22dd84bc62c349

1 files changed, 8 insertions(+), 15 deletions(-)

jump to
M user/zsh/.config/zsh/.zshrcuser/zsh/.config/zsh/.zshrc
@@ -87,29 +87,22 @@ AGKOZAK_PROMPT_DIRTRIM=0   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