From cb1bc18be03a91e47e4ace712db4f178308f652b Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 10 Sep 2020 17:36:55 +0200 Subject: zsh: skip kubernetes rprompt logic when connected via SSH --- user/zsh/zshrc | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'user/zsh/zshrc') 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=' -- cgit 1.4.1