From c1f65b90e7c8728a9412eb0c30d9c0bd13c77817 Mon Sep 17 00:00:00 2001 From: Andrea Mistrali Date: Tue, 25 Feb 2020 13:35:35 +0100 Subject: [PATCH] Fixed regexp matching for AWS Profile --- zsh.d/prompts/pure/pure.zsh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/zsh.d/prompts/pure/pure.zsh b/zsh.d/prompts/pure/pure.zsh index feccea8..e52a274 100644 --- a/zsh.d/prompts/pure/pure.zsh +++ b/zsh.d/prompts/pure/pure.zsh @@ -119,21 +119,24 @@ prompt_pure_set_colors() { } prompt_pure_set_aws() { - local _aws_prod_profile - prompt_pure_aws_prod=0 - prompt_pure_aws= + # YOu can change the pattern to match AWS prod profiles with + # zstyle :awsprofile:prod name pattern , e.g. ^prod + local _aws_prod_profile + prompt_pure_aws_prod=0 + prompt_pure_aws= - if [[ -n $AWS_PROFILE ]]; then - zstyle -g _aws_prod_profile ':awsprofile:prod' 'name' - if [[ -z $_aws_prod_profile ]]; then - _aws_prod_profile='prod' - fi - - if [[ "$AWS_PROFILE" == "$_aws_prod_profile" ]]; then - prompt_pure_aws_prod=1 - fi - prompt_pure_aws="/$AWS_PROFILE/" + if [[ -n $AWS_PROFILE ]]; then + zstyle -g _aws_prod_profile ':awsprofile:prod' 'name' + if [[ -z $_aws_prod_profile ]]; then + #Default pattern if nome specified + _aws_prod_profile='^prod' fi + + if [[ "$AWS_PROFILE" =~ "$_aws_prod_profile" ]]; then + prompt_pure_aws_prod=1 + fi + prompt_pure_aws="/$AWS_PROFILE/" + fi } prompt_pure_preprompt_render() {