[clug] Last command exit code in your prompt string

Brendan Jurd direvus at gmail.com
Wed Mar 13 08:32:16 MDT 2013


A little something for your bashrc.

PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w $(if [ $? == 0 ]; then
echo "\[\033[01;32m\]✓"; else echo "\[\033[01;31m\]✗"; fi)
\$\[\033[00m\] '

I saw this on twitter (courtesy of @selenamarie) and have been using
it the past couple of weeks.  Don't leave home without it.

Cheers,
BJ


More information about the linux mailing list