Skip to content

Instantly share code, notes, and snippets.

@rca
Created December 3, 2012 23:58
Show Gist options
  • Save rca/4199206 to your computer and use it in GitHub Desktop.
Save rca/4199206 to your computer and use it in GitHub Desktop.
show last command's status on prompt and make it red if non-zero
function highlight_status
{
if [ "$1" -ne "0" ]; then
echo -e "\033[31;1m${1}\033[0m"
else
echo 0
fi;
}
export PS1='[$(highlight_status $?)]\u@\h:\w\$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment