Skip to content

Instantly share code, notes, and snippets.

@dougal
Created July 19, 2020 20:42
Show Gist options
  • Save dougal/c8afe1e67113976f7af78ab11c4c4bef to your computer and use it in GitHub Desktop.
Save dougal/c8afe1e67113976f7af78ab11c4c4bef to your computer and use it in GitHub Desktop.
# 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