Last active
February 15, 2018 00:31
-
-
Save hervenivon/499c3900736899c3878be2382e8a6d0d to your computer and use it in GitHub Desktop.
.bash_profile for Amazon Linux DLAMI based (including gdal)
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
# default .bash_profile | |
# Get the aliases and functions | |
if [ -f ~/.bashrc ]; then | |
. ~/.bashrc | |
fi | |
# User specific environment and startup programs | |
PATH=/usr/local/bin/:$HOME/.local/bin:$HOME/bin:$PATH | |
export PATH | |
# --------------------------------------- | |
# 0. Settings for the bash profile | |
# --------------------------------------- | |
set +o history | |
AWS_INSTANCE_ID_DOCUMENT=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document/) | |
AWS_INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
AWS_INSTANCE_PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) | |
AWS_INSTANCE_PRIVATE_IP=$(echo $AWS_INSTANCE_ID_DOCUMENT | jq -r .privateIp) | |
AWS_INSTANCE_IMAGE_ID=$(echo $AWS_INSTANCE_ID_DOCUMENT | jq -r .imageId) | |
AWS_INSTANCE_REGION=$(echo $AWS_INSTANCE_ID_DOCUMENT | jq -r .region) | |
AWS_INSTANCE_TYPE=$(echo $AWS_INSTANCE_ID_DOCUMENT | jq -r .instanceType) | |
AWS_INSTANCE_TAGS=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$AWS_INSTANCE_ID" --region $AWS_INSTANCE_REGION) | |
AWS_INSTANCE_TAG_NAME=$(echo $AWS_INSTANCE_TAGS | jq -r '.Tags[] | select(.Key=="Name") | .Value') | |
# Configure bash_history | |
HISTFILE=$HOME/.bash_history | |
HISTSIZE=500 | |
HISTFILESIZE=500 | |
HISTCONTROL=ignoredups:erasedups | |
shopt -s histappend | |
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND" | |
# --------------------------------------- | |
# 9. Prompt configuration | |
# --------------------------------------- | |
# Red \[\e[31m\] | |
# Green \[\e[32m\] | |
# Blue \[\e[34m\] | |
# Yellow \[\e[33m\] | |
# Cyan \[\e[36m\] | |
# Magenta \[\e[35m\] | |
# Black \[\e[30m\] | |
# White \[\e[37m\] | |
# user \u | |
# pwd \w | |
# directory \W | |
# prompt \\$ | |
# env var \$ENVVAR | |
# errorcode \$? | |
# hh:mm \A | |
export PS1="[ \[\e[31m\]\$AWS_INSTANCE_PUBLIC_IP\[\e[37m\]/\[\e[34m\]\$AWS_INSTANCE_PRIVATE_IP\[\e[37m\] ]\n\[\e[36m\]\u\[\e[37m\]@\[\e[32m\]\$AWS_INSTANCE_TAG_NAME\[\e[37m\](\$AWS_INSTANCE_TYPE):\[\e[33m\]\W\[\e[37m\]\`RETVAL=\$? && if [ \$RETVAL -ne 0 ]; then echo \" \[\e[31m\](\[\e[m\]\$RETVAL\[\e[31m\])\[\e[m\]\"; fi\` \[\e[35m\]\A\[\e[37m\]\\$ " | |
export PATH="/usr/local/gdal/bin:$PATH" | |
export LD_LIBRARY_PATH="/usr/local/proj4/library:/usr/local/gdal/lib:$LD_LIBRARY_PATH" | |
export GDAL_DATA="/usr/local/gdal/share/gdal" | |
# Activate bash history | |
set -o history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment