From 8adfb2610251f29a2bdec0130df74200f78dafd8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 8 Nov 2019 14:14:35 +0100 Subject: zsh: update kubectl prompt setup --- user/zsh/.config/zsh/.zshrc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'user') 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 -- cgit 1.4.1