public
Created

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#!/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'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.