1
1
function __prompt() {
2
2
local -r last_exit_code=$?
3
- local -r use_color=$1
4
- local -r show_host=${2:- no}
3
+
4
+ local -r use_color=" $1 "
5
+ local -r show_host=" ${2:- no} "
5
6
6
7
local -r C_NONE=' \[\e[00m\]'
7
8
local -r C_RED=' \[\e[31m\]'
@@ -31,14 +32,12 @@ function __prompt() {
31
32
git_untracked_files=' *'
32
33
fi
33
34
34
- if [ " $use_color " = yes ]; then
35
- local git_color=' '
35
+ if [ " $use_color " = ' yes' ]; then
36
+ local git_color=$C_GREEN
36
37
if ! git diff --quiet; then
37
- git_color=${ C_RED}
38
+ git_color=$C_RED
38
39
elif ! git diff --cached --quiet; then
39
- git_color=${C_YELLOW}
40
- else
41
- git_color=${C_GREEN}
40
+ git_color=$C_YELLOW
42
41
fi
43
42
44
43
git_prompt=" [${git_color} \$ (__git_ps1 \" %s\" )${C_NONE}${git_untracked_files} ]"
@@ -48,25 +47,30 @@ function __prompt() {
48
47
49
48
fi
50
49
50
+ local hostname=' \h'
51
+ if [ " $show_host " = ' full' ]; then
52
+ hostname=' \H'
53
+ fi
54
+
51
55
local host=' '
52
- if [ " $show_host " = yes ]; then
53
- if [ " $use_color " = yes ]; then
54
- host=" ${C_YELLOW} @${C_BOLD_RED} <${C_HOST} \h ${C_BOLD_RED} >${C_NONE} "
56
+ if [ " $show_host " != ' no ' ]; then
57
+ if [ " $use_color " = ' yes' ]; then
58
+ host=" ${C_YELLOW} @${C_BOLD_RED} <${C_HOST}${hostname} ${C_BOLD_RED} >${C_NONE} "
55
59
else
56
- host=' @!\h! '
60
+ host=" @! ${hostname} ! "
57
61
fi
58
62
fi
59
63
60
64
local error_mark=' '
61
65
if [ " $last_exit_code " -ne 0 ]; then
62
- if [ " $use_color " = yes ]; then
66
+ if [ " $use_color " = ' yes' ]; then
63
67
error_mark=" ${C_BOLD_RED} !${C_NONE} "
64
68
else
65
69
error_mark=' !'
66
70
fi
67
71
fi
68
72
69
- if [ " $use_color " = yes ]; then
73
+ if [ " $use_color " = ' yes' ]; then
70
74
PS1=" ╭─${C_WHITE} \t${C_NONE} \$ {debian_chroot:+(\$ debian_chroot)}${C_USER} \u${C_NONE}${host} : ${C_BOLD_YELLOW} \w${C_NONE}${git_prompt} \n╰─${error_mark}${C_BOLD_PURPLE} \$ ${C_NONE} "
71
75
else
72
76
PS1=" ╭─\t \$ {debian_chroot:+(\$ debian_chroot)}\u${host} : \w${git_prompt} \n╰─${error_mark} \$ "
0 commit comments