Skip to content

Commit

Permalink
fix(aws): do not print region if it's not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed Mar 21, 2023
1 parent 4a39779 commit f9f01e4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugins/aws/aws.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,15 @@ compctl -K _aws_profiles asp acp aws_change_access_key

# AWS prompt
function aws_prompt_info() {
if [[ -z $AWS_REGION && -z $AWS_PROFILE ]];then return; fi
region=${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}
echo "${ZSH_THEME_AWS_PROFILE_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX:=>} ${ZSH_THEME_AWS_REGION_PREFIX:=<region:}${region}${ZSH_THEME_AWS_REGION_SUFFIX:=>}"
local _aws_to_show
if [[ -n $AWS_PROFILE ]];then
_aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX:=>}"
fi
if [[ -n $AWS_REGION ]]; then
[[ -n $AWS_PROFILE ]] && _aws_to_show+=" "
_aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX:=<region:}${region}${ZSH_THEME_AWS_REGION_SUFFIX:=>}"
fi
echo "$_aws_to_show"
}

if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
Expand Down

0 comments on commit f9f01e4

Please sign in to comment.