Skip to content

Instantly share code, notes, and snippets.

@hermannolafs
Last active September 8, 2025 12:51
Show Gist options
  • Save hermannolafs/6f65d8a5f07d342e84ed4c5c89d27869 to your computer and use it in GitHub Desktop.
Save hermannolafs/6f65d8a5f07d342e84ed4c5c89d27869 to your computer and use it in GitHub Desktop.
Fish functions with AWK sprinkles for AWS cli shit
function ecr_profile_login -d "ECR docker login using current profile"
aws ecr get-login-password | docker login --username AWS --password-stdin (aws sts get-caller-identity --query Account --output text).dkr.ecr.(aws configure get region).amazonaws.com
end
function switch_aws_profile -d "sets \$AWS_PROFILE from available profiles"
set -l profile_choice (
awk -F '[][]' '/^\[profile / {
profile_name = $2;
sub(/^profile /, "", profile_name);
print profile_name;
} END {
print "UNSET";
}' ~/.aws/config | fzf)
test -n "$profile_choice"; or return
if test "$profile_choice" = "UNSET"
set -e AWS_PROFILE
echo "AWS_PROFILE unset"
return
end
set -gx AWS_PROFILE "$profile_choice"
echo "AWS_PROFILE=$AWS_PROFILE"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment