Skip to content

Instantly share code, notes, and snippets.

@shawnburke
Created September 19, 2012 16:46
Show Gist options
  • Save shawnburke/3750709 to your computer and use it in GitHub Desktop.
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
# 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