Skip to content

Instantly share code, notes, and snippets.

@pavelanni
Created February 26, 2018 15:15
Show Gist options
  • Save pavelanni/419ba7c9e03d38cbc44d1ef244eeaf9a to your computer and use it in GitHub Desktop.
Save pavelanni/419ba7c9e03d38cbc44d1ef244eeaf9a to your computer and use it in GitHub Desktop.
This changes PS1 on the AWS EC2 instance to show the instance's name (instead of the meaningless internal hostname)
# Borrowed from here: https://stackoverflow.com/questions/18338585/how-to-get-the-instance-name-from-the-instance-in-aws
# This requires AWS CLI to be installed in the instance
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
INSTANCE_NAME=`aws ec2 describe-tags --filters Name=resource-id,Values=$INSTANCE_ID --query Tags[].Value --output text`
export PS1="[\u@$INSTANCE_NAME \W]\\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment