Created
January 11, 2025 22:51
-
-
Save ian-moore/25ef85c0389b60e90f7dbd21b2000963 to your computer and use it in GitHub Desktop.
Small utilities to help with the AWS CLI.
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
#!/usr/bin/env sh | |
# AWS CLI Profile picker | |
# Recommended alias: `awsp` | |
function aws-profiles() { | |
export AWS_PROFILE=$(aws configure list-profiles | fzf) | |
} | |
# AWS CLI Region picker | |
# Recommended alias: `awsr` | |
# Preferred over `aws account list-regions` because this doesn't require authenticating, simply remove regions you do not commonly use | |
function aws-regions() { | |
_region_table=" | |
af-south-1 | |
ap-east-1 | |
ap-northeast-1 | |
ap-northeast-2 | |
ap-northeast-3 | |
ap-south-1 | |
ap-south-2 | |
ap-southeast-1 | |
ap-southeast-2 | |
ap-southeast-3 | |
ap-southeast-4 | |
ap-southeast-5 | |
ap-southeast-7 | |
ca-central-1 | |
ca-west-1 | |
eu-central-1 | |
eu-central-2 | |
eu-north-1 | |
eu-south-1 | |
eu-south-2 | |
eu-west-1 | |
eu-west-2 | |
eu-west-3 | |
il-central-1 | |
me-central-1 | |
me-south-1 | |
sa-east-1 | |
us-east-1 | |
us-east-2 | |
us-west-1 | |
us-west-2 | |
" | |
export AWS_REGION=$(echo $_region_table | fzf) | |
} | |
# AWS environment var string for your terminal prompt | |
_aws_ps1() { | |
local aws_prompt="[%F{#FF9900}aws%f|" | |
if [ -n "$AWS_PROFILE" ]; then | |
aws_prompt+="%F{#A432A8}${AWS_PROFILE}%f" | |
else | |
aws_prompt+="%F{#A432A8}no-profile%f" | |
fi | |
if [ -n "$AWS_REGION" ]; then | |
aws_prompt+=":%F{6}${AWS_REGION}%f" | |
fi | |
echo "${aws_prompt}]" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment