Created
May 9, 2013 16:43
-
-
Save floer32/5548699 to your computer and use it in GitHub Desktop.
Tiny colored prompt. I don't love it, but I've been using it for a while anyways. Best feature is that it is colorized based on the exit status of the 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
######################################### | |
## Prompt stylization and history sync ## | |
######################################### | |
bash_prompt_command() { | |
# Grab exit status of previous command | |
RTN=$? | |
prevCmd=$(prevCmd $RTN) | |
# Save and reload the history after each command finishes | |
history -a; history -c; history -r; | |
} # bash_prompt_command() | |
export PROMPT_COMMAND=bash_prompt_command | |
prevCmd () { | |
if [ $1 == 0 ] ; then | |
echo $GREEN | |
else | |
echo $RED | |
fi | |
} | |
if [ $(tput colors) -gt 0 ] ; then | |
RED=$(tput setaf 1) | |
GREEN=$(tput setaf 2) | |
RST=$(tput op) | |
fi | |
export PS1="\[\e[36m\]\u:\W\[\e[0m\]\[\$prevCmd\]>\[$RST\]" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment