· 
RSS
· 
F
· 
J
· 
P

January 02, 2005

Bash Prompt Colors: Users vs. Root

The following Bash prompt includes hostname, username and current directory, color-coded to differentiate between root and regular users. Select appropriate colors for your shell background.

  • //hostname.root ~>
  • //hostname.username ~>
/etc/bashrc

C_RED="\[\033[0;31m\]"
C_GREEN="\[\033[0;32m\]"
C_LIGHT_GRAY="\[\033[0;37m\]"
C_RESET="\[\033[0m\]"

C_BROWN="\[\033[0;33m\]"
C_BLUE="\[\033[0;34m\]"
C_PURPLE="\[\033[0;35m\]"
C_CYAN="\[\033[0;36m\] "
C_GRAY="\[\033[1;30m\]"
C_WHITE="\[\033[1;37m\]"
C_YELLOW="\[\033[1;33m\]"

C_LIGHT_BLUE="\[\ 033[1;34m\]"
C_LIGHT_CYAN="\[\033[1;36m\]"
C_LIGHT_PURPLE="\[\033[1;35m\]"
C_LIGHT_RED="\[\033[1; 31m\]"
C_LIGHT_GREEN="\[\033[1;32m\]"

PS1="\n$C_GREEN//\h$C_LIGHT_GRAY.\u $C_RESET\w> "

/root/.bashrc

PS1="\n$C_GREEN//\h$C_RED.\u $C_RESET\w> "

Posted by dotpeople at January 2, 2005 02:46 PM