Skip to content

Instantly share code, notes, and snippets.

@tartley
Created July 10, 2012 14:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tartley/3083586 to your computer and use it in GitHub Desktop.
Save tartley/3083586 to your computer and use it in GitHub Desktop.
prepend a red 'last command exit value' to PS1, only for non-zero values.
# display red exit value if it isn't zero
PROMPT_COMMAND='EXITVAL=$?; '$PROMPT_COMMAND
GET_EXITVAL='$(if [[ $EXITVAL != 0 ]]; then echo -n "\[\e[37;41;01m\] $EXITVAL \[\e[0m\] "; fi)'
export PS1="$GET_EXITVAL$PS1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment