From be482242808a138ef0d83fa3cacdb7e267904c56 Mon Sep 17 00:00:00 2001 From: Alexandre Odoux Date: Mon, 22 Aug 2022 13:59:57 +0200 Subject: [PATCH] allow alternate patterns for using green vs. red depending on AWS_PROFILE --- themes/agnoster.zsh-theme | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 5f4efe813..6100a1bee 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -224,20 +224,27 @@ prompt_status() { [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - +# [[ -n "$symbols" ]] && prompt_segment black default "$symbols" } #AWS Profile: # - display current AWS_PROFILE name -# - displays yellow on red if profile name contains 'production' or -# ends in '-prod' +# - displays yellow on red if profile name matches contents of AWS_SENSITIVE_PROFILES +# if AWS_SENSITIVE_PROFILES is not set, then check if profile name ends with -prod or contains *production* # - displays black on green otherwise prompt_aws() { [[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return + + if [ -z $AWS_SENSITIVE_PROFILES ]; then + aws_sensitive_profiles="*-prod|*production*" + else + aws_sensitive_profiles=$AWS_SENSITIVE_PROFILES + fi + case "$AWS_PROFILE" in - *-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;; - *) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;; + $~aws_sensitive_profiles) prompt_segment red yellow "$AWS_PROFILE" ;; + *) prompt_segment green black "$AWS_PROFILE" ;; esac }