Skip to content

Instantly share code, notes, and snippets.

@listrophy
Created April 24, 2010 19:20
Show Gist options
  • Save listrophy/377872 to your computer and use it in GitHub Desktop.
Save listrophy/377872 to your computer and use it in GitHub Desktop.
STRIPPED_PS1="$(echo "$PS1" | sed -e 's/\$ $//')"
function prompt_with_success {
previous_return_value=$?
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
COLOR_NONE="\[\e[0m\]"
if [ $previous_return_value -eq 0 ]
then
PS1="${STRIPPED_PS1}${GREEN}\$${COLOR_NONE} "
else
PS1="${STRIPPED_PS1}${RED}\$${COLOR_NONE} "
fi
}
PROMPT_COMMAND=prompt_with_success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment