Sunday 1 December 2013

Bash PS1 prompt with exit status

Just add the following code to your '~/.bashrc' file,


export PS1='\[\e[01;32m\]\u\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[01;37m\]>\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[01;33m\]\w\[\e[0m\]\[\e[00;37m\]\n\[\e[0m\]\[\e[$(((($?>0))*31))m\]\$\[\e[0m\] '

And then run the following command to apply changes,


source .bashrc

For screenshots and more information read my post here,

A nice looking and useful bash PS1 prompt

Cheers.