More colors in awsprofile

This commit is contained in:
Andrea Mistrali 2021-11-02 10:32:36 +01:00
parent 8b02f06f98
commit 5482387eb3
No known key found for this signature in database
GPG Key ID: 6FB0A77F6D5DA9B2
2 changed files with 9 additions and 5 deletions

View File

@ -5,29 +5,33 @@ if [ $profile ]; then # We got a profile pattern, look for a match
match_no=$(echo $match|wc -l) # Number of profile matching match_no=$(echo $match|wc -l) # Number of profile matching
if [ $match_no -gt 1 ]; then # more than one match if [ $match_no -gt 1 ]; then # more than one match
echo "Multiple profile match:" print -P "$FX[bold]Multiple profile match:"
print -P "$FG[003]"
echo $match echo $match
print -P "$FX[reset]"
return return
fi fi
if [ $match ]; then # Single match, setting profile if [ $match ]; then # Single match, setting profile
echo "Activating profile $match" print -P "$FX[bold]Activating profile $FG[075]$match$FX[reset]"
export AWS_DEFAULT_PROFILE=$match export AWS_DEFAULT_PROFILE=$match
export AWS_PROFILE=$match export AWS_PROFILE=$match
export AWS_DEFAULT_REGION=$(grep -A1 $match ~/.aws/config|grep region|cut -d" " -f3) export AWS_DEFAULT_REGION=$(grep -A1 $match ~/.aws/config|grep region|cut -d" " -f3)
export AWS_REGION=${AWS_DEFAULT_REGION} export AWS_REGION=${AWS_DEFAULT_REGION}
return return
else else
echo "No match for $profile" print -P "$FX[bold]$FG[009]No match for $profile$FX[reset]"
return return
fi fi
elif [ $AWS_PROFILE ]; then # no profile passed, clean up current one, logout elif [ $AWS_PROFILE ]; then # no profile passed, clean up current one, logout
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_DEFAULT_REGION AWS_REGION unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_DEFAULT_REGION AWS_REGION
echo profile cleared. print -P "$FX[bold]profile cleared$FX[reset]."
return return
fi fi
echo "Available profiles" print -P "$FX[bold]Available profiles"
print -P "$FG[075]"
grep profile ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/' grep profile ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/'
print -P "$FX[reset]"
# vim: set ts=2 sw=2 tw=0 ft=sh : # vim: set ts=2 sw=2 tw=0 ft=sh :

Binary file not shown.