blob: 811b15b558c31e9bd7e32ef50cd0d059ea4a0d20 (
plain) (
blame)
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
69
70
71
72
73
74
75
76
77
78
79
|
# If you wish to prevent non KSH shells from running this
# [ -z "$KSH_VERSION" ] && return
# Restrict this to KSH only
if ! [ -z "$KSH_VERSION" ] ; then
precmd() {
typeset e=$?
(( e )) && print -n "$e|"
}
set_ps1() {
PS1='$(precmd)${BG}${ACCENT_C}${ACCENT_P}${USER_C}${USER:=$(id -un)}@$(hostname)${ACCENT_C}${ACCENT_P} ${ACCENT_P}${PATH_C}${PWD:-?}${ACCENT_C}${ACCENT_P}${END_C}
${END_P} [0m'
export PS1;
}
set_root_ps1() {
PS1='$(precmd)${BG}${ACCENT_C}${ACCENT_P}${HOST_C}$(hostname)${ACCENT_C}${ACCENT_P} ${ACCENT_P}${PATH_C}${PWD:-?}${ACCENT_C}${ACCENT_P}${END_C}
${END_P} [0m'
export PS1;
}
# RED: 31, GREEN: 32, YELLOW: 33, BLUE: 34, MAGENTA: 35, CYAN: 36, WHITE: 37, GREY 38. and No color which is 0.
set_prompt() {
if [ `id -u` -eq 0 ] ; then
# Previously
# Red for root, and no username
# PS1="[1;31m[1;40m$(hostname)[1;33m \$PWD
echo $TERM | grep "256color$" > /dev/null 2>&1
if [ $? -eq 0 ] ; then
BG=""
ACCENT_C="[38;5;196m"
ACCENT_P="|"
HOST_C="[38;5;196m"
PATH_C="[38;5;27m"
END_C="[38;5;196m"
set_root_ps1
END_P="#"
else
BG="[1;40m"
ACCENT_C="[0;31m"
ACCENT_P="|"
HOST_C="[1;31m"
PATH_C="[1;33m"
END_P="#"
fi
set_root_ps1
else
# Previously
# PS1="[1;32m[1;40m${USER:=$(id -un)}@$(hostname)[1;33m \$PWD
echo $TERM | grep "256color$" > /dev/null 2>&1
if [ $? -eq 0 ] ; then
BG=""
ACCENT_C="[38;5;21m"
ACCENT_P="|"
USER_C="[38;5;121m"
PATH_C="[38;5;190m"
END_C="[38;5;226m"
END_P="%"
else
BG="[1;40m"
ACCENT_C="[1;34m"
ACCENT_P="|"
USER_C="[1;32m"
PATH_C="[1;33m"
END_C="[1;33m"
END_P="$"
fi
set_ps1
fi
}
set_basic_prompt() {
if [ $(id -u) -eq 0 ] ; then
PS1='$(precmd)'"${USER:=$(id -un)}@$(hostname) \$PWD # "
else
PS1='$(precmd)'"${USER:=$(id -un)}@$(hostname) \$PWD $ "
fi
export PS1;
}
fi
|