mirror of https://github.com/akelge/zsh
awsprofile
renamed awslogin to awsprofile added pattern match
This commit is contained in:
parent
4166f55fd4
commit
3d9237d5ce
|
@ -1,22 +0,0 @@
|
|||
profile=$1
|
||||
|
||||
if [ $profile ]; then
|
||||
match=$(grep $profile ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/')
|
||||
if [ $match ]; then
|
||||
echo "Activating $match"
|
||||
export AWS_DEFAULT_PROFILE=$match
|
||||
export AWS_PROFILE=$match
|
||||
export AWS_EB_PROFILE=$match
|
||||
return
|
||||
else
|
||||
echo "No match for $profile"
|
||||
return
|
||||
fi
|
||||
elif [ $AWS_PROFILE ]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Available profiles"
|
||||
grep profile ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/'
|
Binary file not shown.
|
@ -0,0 +1,30 @@
|
|||
profile=$1
|
||||
|
||||
if [ $profile ]; then # We got a profile pattern, look for a match
|
||||
match=$(grep -E "\[profile .*$profile.*" ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/')
|
||||
match_no=$(echo $match|wc -l)
|
||||
if [ $match_no -gt 1 ]; then # more than one match
|
||||
echo "Multiple matches:"
|
||||
echo $match
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $match ]; then # Single match, setting profile
|
||||
echo "Activating $match"
|
||||
export AWS_DEFAULT_PROFILE=$match
|
||||
export AWS_PROFILE=$match
|
||||
export AWS_EB_PROFILE=$match
|
||||
return
|
||||
else
|
||||
echo "No match for $profile"
|
||||
return
|
||||
fi
|
||||
elif [ $AWS_PROFILE ]; then # no profile passed, clean up current one, logout
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
||||
echo profile cleared.
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Available profiles"
|
||||
grep profile ~/.aws/config | sed -E 's/\[profile (.+)\]/\1/'
|
||||
# vim: set ts=2 sw=2 tw=0 ft=sh :
|
Binary file not shown.
Loading…
Reference in New Issue