Last active
July 4, 2025 07:33
-
-
Save kenzo0107/c647d400501a1e63c96df5389cf5dbe6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# AWS Profile Selector with awsume and peco | |
# Usage: ./aws-profile-selector.sh | |
set -e | |
# Check if required commands are available | |
if ! command -v awsume &> /dev/null; then | |
echo "Error: awsume is not installed or not in PATH" | |
exit 1 | |
fi | |
if ! command -v peco &> /dev/null; then | |
echo "Error: peco is not installed or not in PATH" | |
exit 1 | |
fi | |
# Get available profiles from awsume | |
profiles=$(awsume -l 2>/dev/null | grep -v "^$" | grep -v "Available profiles:" | grep -v "^-" | grep -v "^=*AWS" | grep -v "PROFILE" | grep -v "^default$" | awk '{print $1}') | |
if [ -z "$profiles" ]; then | |
echo "No AWS profiles found" | |
exit 1 | |
fi | |
# Select profile using peco | |
selected_profile=$(echo "$profiles" | peco --prompt="Select AWS Profile: ") | |
if [ -z "$selected_profile" ]; then | |
echo "No profile selected" | |
exit 0 | |
fi | |
echo "Switching to: $selected_profile" | |
# . awsume --session-name <your user name> "$selected_profile" | |
. awsume --session-name $USERNAME "$selected_profile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment