File tree 3 files changed +16
-2
lines changed
3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,7 @@ PROMPT_COMMAND="__prompt $color_prompt yes"
30
30
When the user is root:
31
31
32
32
![ When root] ( screen3.png )
33
+
34
+ When the last exit status iz not zero:
35
+
36
+ ![ Non-zero exit status] ( screen4.png )
Original file line number Diff line number Diff line change 1
1
function __prompt() {
2
+ local -r last_exit_code=$?
2
3
local -r use_color=$1
3
4
local -r show_host=${2:- no}
4
5
@@ -56,9 +57,18 @@ function __prompt() {
56
57
fi
57
58
fi
58
59
60
+ local error_mark=' '
61
+ if [ " $last_exit_code " -ne 0 ]; then
62
+ if [ " $use_color " = yes ]; then
63
+ error_mark=" ${C_BOLD_RED} !${C_NONE} "
64
+ else
65
+ error_mark=' !'
66
+ fi
67
+ fi
68
+
59
69
if [ " $use_color " = yes ]; then
60
- 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╰─${C_BOLD_PURPLE} \$ ${C_NONE} "
70
+ 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} "
61
71
else
62
- PS1=" ╭─\t \$ {debian_chroot:+(\$ debian_chroot)}\u${host} : \w${git_prompt} \n╰─\$ "
72
+ PS1=" ╭─\t \$ {debian_chroot:+(\$ debian_chroot)}\u${host} : \w${git_prompt} \n╰─${error_mark} \$ "
63
73
fi
64
74
}
You can’t perform that action at this time.
0 commit comments