Skip to content

Instantly share code, notes, and snippets.

@bmoyles
Created November 7, 2019 17:37
Show Gist options
  • Save bmoyles/c8f70a60d7a80d7a511230480c15b306 to your computer and use it in GitHub Desktop.
Save bmoyles/c8f70a60d7a80d7a511230480c15b306 to your computer and use it in GitHub Desktop.
our standard prompt
color_prompt=
if [[ -z ${NO_COLOR_PROMPT:-} ]] && \
[[ ! -e ${HOME}/.no_color_prompt ]] && \
[[ -r /etc/bash_colors ]]
then
if [[ -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
fi
fi
_prompt_user='(\u)'
if [[ ${color_prompt} == yes ]]; then
. /etc/bash_colors
_prompt_env="${BRIGHT_RED}\${NETFLIX_ACCOUNT:-\${NETFLIX_ENVIRONMENT:-no env/account}}${NORMAL}"
_prompt_asg="${BRIGHT_GREEN}\${NETFLIX_AUTO_SCALE_GROUP:-no asg}${NORMAL}"
_prompt_region="${BRIGHT_YELLOW}\${EC2_REGION:-no region}${NORMAL}"
# Backward compatibility for anything that may not have the Netflix instance id set
if [[ "${NETFLIX_INSTANCE_ID}" != "" ]]; then
_prompt_id="${BRIGHT_CYAN}\${NETFLIX_INSTANCE_ID:-no id}${NORMAL}"
else
_prompt_id="${BRIGHT_CYAN}\${EC2_INSTANCE_ID:-no id}${NORMAL}"
fi
if (( UID == 0 )); then
_prompt_user="(${BRIGHT_RED}root${NORMAL})"
fi
else
_prompt_env="\${NETFLIX_ACCOUNT:-\${NETFLIX_ENVIRONMENT}}"
_prompt_asg="\${NETFLIX_AUTO_SCALE_GROUP}"
_prompt_region="\${EC2_REGION}"
# Backward compatibility for anything that may not have the Netflix instance id set
if [[ "${NETFLIX_INSTANCE_ID}" != "" ]]; then
_prompt_id="\${NETFLIX_INSTANCE_ID}"
else
_prompt_id="\${EC2_INSTANCE_ID}"
fi
fi
export PS1="\n${_prompt_env} ${_prompt_asg} ${_prompt_region} ${_prompt_id}\n${_prompt_user} \w \\$ "
unset color_prompt _prompt_user _prompt_env _prompt_asg _prompt_region _prompt_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment