I use this, which allows a similar effect but is enabled for PIPESTATUS, and also does some good things for eterm and screen.
PIPESTATUS_REGEX="^ +$"
# check to see if any of the pipe statuses don't start with 0
# ${_CMD_PIPESTATUS[@]#0} results in null if they all do
_PIPESTATUS="
_CMD_PIPESTATUS=(\${PIPESTATUS[@]})
if [[ \"\${_CMD_PIPESTATUS[*]#0}\" && ! \"\${_CMD_PIPESTATUS[*]#0}\" =~ \$PIPESTATUS_REGEX ]]
then
_RES_STR=\" [\${_CMD_PIPESTATUS[*]}]\";
else
_RES_STR=''
fi"
export PROMPT_COMMAND="$_PIPESTATUS; $PROMPT_COMMAND"
if [[ $TERM = screen || $_TERM = screen ]]; then
_RESET_PROMPT="\[\033k\033\\\\\]"
else
_RESET_PROMPT=""
fi
if [ $TERM = "eterm-color" ]; then
# XXX: this is going to break things when you start
# use $INSIDE_EMACS to test whether we should use \u?
_ETERM_PROMPT="\[\033AnSiTu \u\012\033AnSiTc \w\012\033AnSiTh \H\012\]"
else
_ETERM_PROMPT=""
fi
export PS1="\n$_ETERM_PROMPT\[\033[32m\]\u@\h \[\033[33m\]\w\[\033[35m\]\$_RES_STR\[\033[0m\]\n${_RESET_PROMPT}\\$ "
unset _RESET_PROMPT
It's cool to also see the name of the signal that caused exit status > 128. Sadly this only fits in a tweet if it can assume the possible signal names are listed contiguously, which isn't so on 64-bit Linux these days.
S=(`trap -l`);e(){ for N in ${PIPESTATUS[@]};do ((N>128))&&echo ${S[$((2*N-257))]}||echo $N;done;};trap $'echo "\e[41m Exit "`e`" \e[m"' ERR