Created
February 26, 2018 15:15
-
-
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)
This file contains hidden or 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
# 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