Created
October 12, 2010 00:19
-
-
Save nothingmuch/621452 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
_set_prompt () { | |
local exit=$? | |
#local black="30"; | |
#local grey="31"; | |
local red="31"; | |
local green="32"; | |
local yellow="33"; | |
#local blue="34"; | |
#local purple="35"; | |
local cyan="36"; | |
local white="37"; | |
local pre="\[\e["; | |
local suf="\]"; | |
# public values | |
GREEN="${pre}0;${green}m$suf"; | |
#BLUE="${pre}0;${blue}m$suf"; | |
CYAN="${pre}0;${cyan}m$suf"; | |
WHITE="${pre}0;${white}m$suf"; | |
#BWHITE="$pre$white;1m$suf"; | |
BRED="$pre$red;1m$suf"; | |
#YELLOW="${pre}0;${yellow}m$suf"; | |
BYELLOW="$pre$yellow;1m$suf"; | |
NORMAL="\[\e[0;0m\]" | |
local u; | |
local p; | |
if [ "$UID" = "0" ]; then | |
u="$BRED\u$NORMAL"; | |
p="$BRED#$NORMAL"; | |
else | |
u="$BYELLOW\u$NORMAL"; | |
p="%"; | |
fi | |
_prompt="[$WHITE\h$NORMAL:$CYAN\w$NORMAL] $u $p "; | |
} | |
_update_prompt () { | |
local exit="$?" | |
local bul="\342\200\242" # bullet character | |
case "$exit" in | |
"0" ) ex="$GREEN$bul$NORMAL " ;; | |
* ) ex="$BRED$bul$NORMAL " ;; | |
esac | |
export PS1="$ex$_prompt"; | |
} | |
_set_prompt | |
PROMPT_COMMAND='_update_prompt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment