Created
July 19, 2020 20:42
-
-
Save dougal/c8afe1e67113976f7af78ab11c4c4bef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to set the current AWS Profile. | |
# | |
# Checks to see if the profile exists before setting it. | |
set AWS_PROFILES_PATH $HOME/.aws/credentials | |
function awsprofile | |
set target_profile $argv | |
if test -z $target_profile | |
echo $AWS_PROFILE | |
return | |
end | |
# Check there is such a profile. | |
if grep -Fxq "[$target_profile]" ~/.aws/credentials | |
echo $target_profile | |
# Use -g to set global scope, so inside current shell, not just inside this function. | |
set -gx AWS_PROFILE $target_profile | |
else | |
echo "Profile does not exist: $target_profile" | |
return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment