Skip to content

Instantly share code, notes, and snippets.

@15joeybloom
Last active February 17, 2020 20:51
Show Gist options
  • Save 15joeybloom/3a24c60b191836deed144c760a0799e0 to your computer and use it in GitHub Desktop.
Save 15joeybloom/3a24c60b191836deed144c760a0799e0 to your computer and use it in GitHub Desktop.
A dynamic bash prompt displaying the value (if any) of the AWS_PROFILE environment variable.
# https://gist.github.com/15joeybloom/3a24c60b191836deed144c760a0799e0
aws_profile_prompt() {
if [ -z "${AWS_PROFILE+foo}" ] ; then # Check if AWS_PROFILE set
printf ""
elif [ -z "$AWS_PROFILE" ] ; then # Check if AWS_PROFILE empty
# italic, red bg, black fg
printf "\001\033[3;48;5;1;38;5;16m\002AWS Profile empty!\001\033[0m\002 "
else
# bold, yellow bg, black fg
printf "\001\033[1;48;5;220;38;5;16m\002AWS Profile: $AWS_PROFILE\001\033[0m\002 "
fi
}
export PS1="\$(aws_profile_prompt)$PS1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment