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 65 66 67 68 | R="\[\e[m\]"
RESET="\[\e[m\]"
BOLD="\[\e[1m\]"
FAINT="\[\e[2m\]"
UNDERLINE="\[\e[4m\]"
REVERSE="\[\e[7m\]"
STRIKEOUT="\[\e[9m\]"
LO_BLACK="\[\e[30m\]"
LO_RED="\[\e[31m\]"
LO_GREEN="\[\e[32m\]"
LO_YELLOW="\[\e[33m\]"
LO_BLUE="\[\e[34m\]"
LO_MAGENTA="\[\e[35m\]"
LO_CYAN="\[\e[36m\]"
LO_WHITE="\[\e[37m\]"
HI_BLACK="\[\e[30;90m\]"
HI_RED="\[\e[31;91m\]"
HI_GREEN="\[\e[32;92m\]"
HI_YELLOW="\[\e[33;93m\]"
HI_BLUE="\[\e[34;94m\]"
HI_MAGENTA="\[\e[35;95m\]"
HI_CYAN="\[\e[36;96m\]"
HI_WHITE="\[\e[37;97m\]"
BG_BLACK="\[\e[40m\]"
BG_RED="\[\e[41m\]"
BG_GREEN="\[\e[42m\]"
BG_YELLOW="\[\e[43m\]"
BG_BLUE="\[\e[44m\]"
BG_MAGENTA="\[\e[45m\]"
BG_CYAN="\[\e[46m\]"
BG_WHITE="\[\e[47m\]"
# ======================= BASH PROMPT ESCAPE CODES ==========================
# == Time & Date ==
# \t Time in 24-hour HH:MM:SS format \T Time in 12-hour HH:MM:SS format
# \A Time in 24-hour HH:MM format \@ Time in 12-hour HH:MM AP format
# \d Date, e.g. "Tue May 26"
#
# == Characters ==
# \a ASCII bell \e ASCII escape character
# \n Newline \r Carriage return
# \[ Start of non-printing characters \] End of non-printing characters
# \\ A backslash
#
# == Shell Info ==
# \v Short version (e.g. "4.0") \V Long version (e.g. "4.0.33")
# \! History number of this command \# Command number of this command
# \j Number of jobs \l Basename of the shell's terminal device
# \s Shell name (e.g. "bash")
#
# == Current Environment ==
# \h Short hostname \H Full hostname
# \w Current working directory \W Basename of the current directory
# \u Current username
# \$ Shell prompt (either '$' or '#')
#
if [ `whoami` = "root" ]
then
export PS1="$BG_RED$HI_YELLOW\u${HI_WHITE}@${HI_YELLOW}\h$HI_BLACK:$HI_GREEN\w $HI_WHITE\$$R "
else
export PS1="$BG_BLUE$LO_CYAN\u${HI_CYAN}@${LO_CYAN}\h$HI_BLACK:$HI_GREEN\w $HI_WHITE\$$R "
#export PS1="$BG_BLUE$LO_MAGENTA\u${HI_MAGENTA}@${LO_MAGENTA}\h$HI_BLACK:$HI_GREEN\w $HI_WHITE\$$R "
#export PS1="$BG_BLUE$LO_GREEN\u${HI_GREEN}@${LO_GREEN}\h$HI_BLACK:$HI_GREEN\w $HI_WHITE\$$R "
fi
unset R RESET BOLD FAINT UNDERLINE REVERSE STRIKEOUT LO_BLACK LO_RED LO_GREEN LO_YELLOW LO_BLUE LO_MAGENTA LO_CYAN LO_WHITE HI_BLACK HI_RED HI_GREEN HI_YELLOW HI_BLUE HI_MAGENTA HI_CYAN HI_WHITE BG_BLACK BG_RED BG_GREEN BG_YELLOW BG_BLUE BG_MAGENTA BG_CYAN BG_WHITE
|
x
Notes
Features:
- Easily editable with color code variables
- Root shell is auto-detected and provided with a different format (red by default)
- Prompt format is copy/pastable to scp/rsync format