Last active
August 29, 2015 13:57
-
-
Save charlesthomas/9696225 to your computer and use it in GitHub Desktop.
color prompt based on exit status of previous command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NONE="\e[0m" | |
RED="\e[0;31m" | |
GREEN="\e[0;32m" | |
function last_exit_prompt() { | |
if [[ $? -eq 0 ]]; then | |
PS1="${PS1}\n\[${GREEN}\]>> \[${NONE}\]" | |
else | |
PS1="${PS1}\n\[${RED}\]>> \[${NONE}\]" | |
fi | |
} | |
PROMPT_COMMAND="last_exit_prompt;$PROMPT_COMMAND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment