Skip to content

Instantly share code, notes, and snippets.

@ahamilton55
Created November 14, 2012 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahamilton55/4075198 to your computer and use it in GitHub Desktop.
Save ahamilton55/4075198 to your computer and use it in GitHub Desktop.
Add the current account name and user to the BASH prompt
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)
EC2_USER_NAME=$(basename $EC2_CERT | cut -d'-' -f2)
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)
EC2_USER_NAME=$(basename $EC2_CERT | cut -d'-' -f2)
fi
fi
echo "${EC2_ACCOUNT_NAME}:${EC2_USER_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