-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bash_prompt
47 lines (39 loc) · 1.1 KB
/
dot_bash_prompt
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
#!/usr/bin/env bash
LIGHT_RED="\[\033[1;31m\]"
LIGHT_YELLOW="\[\033[1;33m\]"
CYAN="\[\033[0;36m\]"
LIGHT_CYAN="\[\033[1;36m\]"
WHITE="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
# Return the prompt symbol to use, colorized based on the return value of the
# previous command.
function set_prompt_symbol () {
if test "$(id -u)" -eq 0; then
SYM="#"
else
SYM="\$"
fi
if test "$1" -eq 0 ; then
PROMPT_SYMBOL="${SYM}"
else
PROMPT_SYMBOL="${LIGHT_RED}$1 ${SYM}${COLOR_NONE}"
fi
}
function set_date_prompt () {
DATE_PROMPT="${WHITE}$(date +'%H:%M:%S')${COLOR_NONE} "
}
# Set the full bash prompt.
function set_bash_prompt () {
# Set the PROMPT_SYMBOL variable. We do this first so we don't lose the
# return value of the last command.
set_prompt_symbol $?
# set date string
set_date_prompt
USERLINE="${CYAN}\u@${LIGHT_CYAN}\h${COLOR_NONE}:${LIGHT_YELLOW}\w${COLOR_NONE} "
# Set the bash prompt variable.
PS1="
${USERLINE}
${DATE_PROMPT}${PROMPT_SYMBOL} "
}
# Tell bash to execute this function just before displaying its prompt.
PROMPT_COMMAND=set_bash_prompt