Prefixes a return code to the prompt and colors it green if 0, otherwise red.
Bash users.
In ~/.bashrc
, create a function like this:
rcc() {
if [[ $? -eq 0 ]]; then
echo -e '\e[0;32m'$?'\e[0;0m'
else
echo -e '\e[0;31m'$?'\e[0;0m'
fi
}
Then edit your $PS1
to call rcc()
. Example:
PS1='[`rcc`|\u@\h \W]\$ '