Skip to content

Instantly share code, notes, and snippets.

View tartley's full-sized avatar
🐍
Mostly wrangling Pythons

Jonathan Hartley tartley

🐍
Mostly wrangling Pythons
View GitHub Profile
@tartley
tartley / exitval in ps1
Created July 10, 2012 14:22
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"