Created
November 14, 2012 21:57
-
-
Save ahamilton55/4075118 to your computer and use it in GitHub Desktop.
Add the current account name to a BASH prompt
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
parse_euca_user() { | |
if [[ ! -z ${EC2_USER_ID} ]]; then | |
if [[ ! -e ${HOME}/.my_ec2_user_id || $(cat ${HOME}/.my_ec2_user_id | cut -d' ' -f1) -ne ${EC2_USER_ID} ]]; then | |
EC2_ACCOUNT_NAME=$(euare-accountlist | grep $EC2_USER_ID | cut -d' ' -f1) | |
echo ${EC2_USER_ID} ${EC2_ACCOUNT_NAME} >${HOME}/.my_ec2_user_id | |
else | |
EC2_ACCOUNT_NAME=$(cat $HOME/.my_ec2_user_id | cut -d' ' -f2) | |
fi | |
fi | |
echo ${EC2_ACCOUNT_NAME} | |
} | |
export PS1="\u@\h:\w (\$(parse_euca_user))\$ " | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment