Skip to content

Commit e476910

Browse files
committedJan 18, 2023
Add special colors for root
1 parent d36fe05 commit e476910

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
 

‎README.md

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ PROMPT_COMMAND="__prompt $color_prompt yes"
2626
```
2727

2828
![With the hostname](screen2.png)
29+
30+
When the user is root:
31+
32+
![When root](screen3.png)

‎prompt.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ function __prompt() {
1212
local -r C_BOLD_GREEN='\[\e[01;32m\]'
1313
local -r C_BOLD_YELLOW='\[\e[01;33m\]'
1414
local -r C_BOLD_PURPLE='\[\e[01;35m\]'
15+
local -r C_BOLD_CYAN='\[\e[01;36m\]'
16+
17+
if [ "$UID" = 0 ]; then
18+
local -r C_USER=$C_RED
19+
local -r C_HOST=$C_BOLD_CYAN
20+
else
21+
local -r C_USER=$C_CYAN
22+
local -r C_HOST=$C_BOLD_GREEN
23+
fi
1524

1625
local git_prompt=''
1726
if git rev-parse --git-dir >/dev/null 2>&1; then
@@ -41,14 +50,14 @@ function __prompt() {
4150
local host=''
4251
if [ "$show_host" = yes ]; then
4352
if [ "$use_color" = yes ]; then
44-
host="${C_YELLOW}@${C_BOLD_RED}<${C_BOLD_GREEN}\h${C_BOLD_RED}>${C_NONE}"
53+
host="${C_YELLOW}@${C_BOLD_RED}<${C_HOST}\h${C_BOLD_RED}>${C_NONE}"
4554
else
4655
host='@!\h!'
4756
fi
4857
fi
4958

5059
if [ "$use_color" = yes ]; then
51-
PS1="╭─${C_WHITE}\t${C_NONE} \${debian_chroot:+(\$debian_chroot)}${C_CYAN}\u${C_NONE}${host}: ${C_BOLD_YELLOW}\w${C_NONE}${git_prompt}\n╰─${C_BOLD_PURPLE}\$${C_NONE} "
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} "
5261
else
5362
PS1="╭─\t \${debian_chroot:+(\$debian_chroot)}\u${host}: \w${git_prompt}\n╰─\$ "
5463
fi

‎screen3.png

7.43 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.