I like to have a pretty obvious indication of the success of failure of any commands I might have run. To accomplish this I add several color coding shortcuts to my
RED='\033[0;31m' GREEN='\033[0;32m' BLUE='\033[0;34m' NOFORMAT='\033[m' #return code visualization RVAL='$(RET=$?; if [ $RET -eq 0 ]; then echo -ne "$GREEN"; else echo -ne "$RED"; fi; echo -ne "$RET")'
Using those I can make a relatively simple
$PS1 that I add to the end of my
# prompt export PS1="$BLUE\t $NOFORMAT\h $BLUE\w $RVAL\r\n\\\$ "
That gives me a prompt that looks like this for root after a successful command:
or like this for a normal user after a failed command (
CTRL-C in this case):
I personally don't put any color changes after the newline
\n. It tends to lead to funky things when scrolling through your history or dealing with really long commands.