summary refs log tree commit diff stats
path: root/user/zsh/zshrc
diff options
context:
space:
mode:
authorAlan Pearce2020-09-10 17:36:55 +0200
committerAlan Pearce2020-09-10 17:36:55 +0200
commitcb1bc18be03a91e47e4ace712db4f178308f652b (patch)
treecbc7632b781c347f5133d48ce0985866248676f5 /user/zsh/zshrc
parent6569d5745f38129d7a2d446a201ef3190c0030b2 (diff)
downloadnixfiles-cb1bc18be03a91e47e4ace712db4f178308f652b.tar.lz
nixfiles-cb1bc18be03a91e47e4ace712db4f178308f652b.tar.zst
nixfiles-cb1bc18be03a91e47e4ace712db4f178308f652b.zip
zsh: skip kubernetes rprompt logic when connected via SSH
Diffstat (limited to 'user/zsh/zshrc')
-rw-r--r--user/zsh/zshrc43
1 files changed, 23 insertions, 20 deletions
diff --git a/user/zsh/zshrc b/user/zsh/zshrc
index 6632490e..67eee653 100644
--- a/user/zsh/zshrc
+++ b/user/zsh/zshrc
@@ -81,31 +81,34 @@ else
   AGKOZAK_PROMPT_DIRTRIM=0
   AGKOZAK_LEFT_PROMPT_ONLY=${+SSH_CLIENT}
 
-  check_kubectl_context () {
-    if [[ "$PWD" =~ satoshipay ]]
-    then
-      kubectl_context=$(kubectl config current-context)
-      kubectl_namespace=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"${kubectl_context}\")].context.namespace}")
-      if [[ $kubectl_context =~ production ]]
+  if [[ -z $SSH_CLIENT ]]
+  then
+    check_kubectl_context () {
+      if [[ "$PWD" =~ satoshipay ]]
       then
-        kubectl_colour=red
-        kubectl_release=satoshipay-${kubectl_namespace}
-      else
-        kubectl_colour=yellow
-        if [[ -z $mr ]]
+        kubectl_context=$(kubectl config current-context)
+        kubectl_namespace=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"${kubectl_context}\")].context.namespace}")
+        if [[ $kubectl_context =~ production ]]
         then
-          kubectl_release=satoshipay-${kubectl_namespace}-staging
+          kubectl_colour=red
+          kubectl_release=satoshipay-${kubectl_namespace}
         else
-          kubectl_release=story-${mr}-${kubectl_namespace}
+          kubectl_colour=yellow
+          if [[ -z $mr ]]
+          then
+            kubectl_release=satoshipay-${kubectl_namespace}-staging
+          else
+            kubectl_release=story-${mr}-${kubectl_namespace}
+          fi
         fi
-      fi
         prompt_context="%F{$kubectl_colour}[${kubectl_context}:${kubectl_namespace}]%f"
-    else
-      prompt_context=
-    fi
-  }
-  precmd_functions+=(check_kubectl_context)
-  AGKOZAK_CUSTOM_RPROMPT='${prompt_context}%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}%3v%f.)'
+      else
+        prompt_context=
+      fi
+    }
+    precmd_functions+=(check_kubectl_context)
+    AGKOZAK_CUSTOM_RPROMPT='${prompt_context}%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}%3v%f.)'
+  fi
 fi
 
 export FZF_CTRL_T_COMMAND='