Stick something like this in your .bashrc file:

# display red exit value if it isn't zero
GET_EXITVAL='$(if [[ $EXITVAL != 0 ]]; then echo -n "\[\e[37;41;01m\] $EXITVAL \[\e[0m\] "; fi)'
export PS1="$GET_EXITVAL$PS1"

Command exit values other than zero are displayed in the subsequent prompt:

Check out the little red '1'

(see the little red ‘1’).

It’s the


bit which includes the last command exit value in the prompt, unless the value is zero, in which case nothing is displayed.