Created
September 19, 2012 16:46
-
-
Save shawnburke/3750709 to your computer and use it in GitHub Desktop.
Partial bash script for setting prompt to EC2 instance name. Add this to .bashrc
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
# these make the ec2 commands just work | |
export AWS_ACCESS_KEY=[AWS access key] | |
export AWS_SECRET_KEY=[AWS secret] | |
# fetch the instance id | |
export INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id) | |
#grep out the tag you're looking for, in this case "Name" | |
export APP_TAG=$(ec2-describe-tags | grep $INSTANCE_ID | grep -oE "Name\\W+(.+)$" | grep -oE "\\W.+$") | |
#put it into the prompt | |
export PS1="$APP_TAG:\W>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment