Last active
February 17, 2020 20:51
-
-
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.
This file contains 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
# 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