Skip to content

Commit f26c87e

Browse files
authored
Merge pull request #94 from richlamdev/update-git-prompt
update git custom prompt
2 parents a653b1b + 3f0e28f commit f26c87e

File tree

1 file changed

+59
-61
lines changed

1 file changed

+59
-61
lines changed

roles/env/files/git_bash_ps1.sh

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,83 +6,81 @@
66
# I don't remember where I found this. o_O
77

88
# Reset
9-
Color_Off="\[\033[0m\]" # Text Reset
9+
Color_Off="\[\033[0m\]" # Text Reset
1010

1111
# Regular Colors
12-
Black="\[\033[0;30m\]" # Black
13-
Red="\[\033[0;31m\]" # Red
14-
Green="\[\033[0;32m\]" # Green
15-
Yellow="\[\033[0;33m\]" # Yellow
16-
Blue="\[\033[0;34m\]" # Blue
17-
Purple="\[\033[0;35m\]" # Purple
18-
Cyan="\[\033[0;36m\]" # Cyan
19-
White="\[\033[0;37m\]" # White
12+
Black="\[\033[0;30m\]" # Black
13+
Red="\[\033[0;31m\]" # Red
14+
Green="\[\033[0;32m\]" # Green
15+
Yellow="\[\033[0;33m\]" # Yellow
16+
Blue="\[\033[0;34m\]" # Blue
17+
Purple="\[\033[0;35m\]" # Purple
18+
Cyan="\[\033[0;36m\]" # Cyan
19+
White="\[\033[0;37m\]" # White
2020

2121
Yellow226="\[\033[01;38;5;226m\]"
2222
LightPink207="\[\033[01;38;5;207m\]"
2323
Blue027="\[\033[01;38;5;027m\]"
2424

25-
2625
# Bold
27-
BBlack="\[\033[1;30m\]" # Black
28-
BRed="\[\033[1;31m\]" # Red
29-
BGreen="\[\033[1;32m\]" # Green
30-
BYellow="\[\033[1;33m\]" # Yellow
31-
BBlue="\[\033[1;34m\]" # Blue
32-
BPurple="\[\033[1;35m\]" # Purple
33-
BCyan="\[\033[1;36m\]" # Cyan
34-
BWhite="\[\033[1;37m\]" # White
26+
BBlack="\[\033[1;30m\]" # Black
27+
BRed="\[\033[1;31m\]" # Red
28+
BGreen="\[\033[1;32m\]" # Green
29+
BYellow="\[\033[1;33m\]" # Yellow
30+
BBlue="\[\033[1;34m\]" # Blue
31+
BPurple="\[\033[1;35m\]" # Purple
32+
BCyan="\[\033[1;36m\]" # Cyan
33+
BWhite="\[\033[1;37m\]" # White
3534

3635
# Underline
37-
UBlack="\[\033[4;30m\]" # Black
38-
URed="\[\033[4;31m\]" # Red
39-
UGreen="\[\033[4;32m\]" # Green
40-
UYellow="\[\033[4;33m\]" # Yellow
41-
UBlue="\[\033[4;34m\]" # Blue
42-
UPurple="\[\033[4;35m\]" # Purple
43-
UCyan="\[\033[4;36m\]" # Cyan
44-
UWhite="\[\033[4;37m\]" # White
36+
UBlack="\[\033[4;30m\]" # Black
37+
URed="\[\033[4;31m\]" # Red
38+
UGreen="\[\033[4;32m\]" # Green
39+
UYellow="\[\033[4;33m\]" # Yellow
40+
UBlue="\[\033[4;34m\]" # Blue
41+
UPurple="\[\033[4;35m\]" # Purple
42+
UCyan="\[\033[4;36m\]" # Cyan
43+
UWhite="\[\033[4;37m\]" # White
4544

4645
# Background
47-
On_Black="\[\033[40m\]" # Black
48-
On_Red="\[\033[41m\]" # Red
49-
On_Green="\[\033[42m\]" # Green
50-
On_Yellow="\[\033[43m\]" # Yellow
51-
On_Blue="\[\033[44m\]" # Blue
52-
On_Purple="\[\033[45m\]" # Purple
53-
On_Cyan="\[\033[46m\]" # Cyan
54-
On_White="\[\033[47m\]" # White
46+
On_Black="\[\033[40m\]" # Black
47+
On_Red="\[\033[41m\]" # Red
48+
On_Green="\[\033[42m\]" # Green
49+
On_Yellow="\[\033[43m\]" # Yellow
50+
On_Blue="\[\033[44m\]" # Blue
51+
On_Purple="\[\033[45m\]" # Purple
52+
On_Cyan="\[\033[46m\]" # Cyan
53+
On_White="\[\033[47m\]" # White
5554

5655
# High Intensty
57-
IBlack="\[\033[0;90m\]" # Black
58-
IRed="\[\033[0;91m\]" # Red
59-
IGreen="\[\033[0;92m\]" # Green
60-
IYellow="\[\033[0;93m\]" # Yellow
61-
IBlue="\[\033[0;94m\]" # Blue
62-
IPurple="\[\033[0;95m\]" # Purple
63-
ICyan="\[\033[0;96m\]" # Cyan
64-
IWhite="\[\033[0;97m\]" # White
56+
IBlack="\[\033[0;90m\]" # Black
57+
IRed="\[\033[0;91m\]" # Red
58+
IGreen="\[\033[0;92m\]" # Green
59+
IYellow="\[\033[0;93m\]" # Yellow
60+
IBlue="\[\033[0;94m\]" # Blue
61+
IPurple="\[\033[0;95m\]" # Purple
62+
ICyan="\[\033[0;96m\]" # Cyan
63+
IWhite="\[\033[0;97m\]" # White
6564

6665
# Bold High Intensty
67-
BIBlack="\[\033[1;90m\]" # Black
68-
BIRed="\[\033[1;91m\]" # Red
69-
BIGreen="\[\033[1;92m\]" # Green
70-
BIYellow="\[\033[1;93m\]" # Yellow
71-
BIBlue="\[\033[1;94m\]" # Blue
72-
BIPurple="\[\033[1;95m\]" # Purple
73-
BICyan="\[\033[1;96m\]" # Cyan
74-
BIWhite="\[\033[1;97m\]" # White
66+
BIBlack="\[\033[1;90m\]" # Black
67+
BIRed="\[\033[1;91m\]" # Red
68+
BIGreen="\[\033[1;92m\]" # Green
69+
BIYellow="\[\033[1;93m\]" # Yellow
70+
BIBlue="\[\033[1;94m\]" # Blue
71+
BIPurple="\[\033[1;95m\]" # Purple
72+
BICyan="\[\033[1;96m\]" # Cyan
73+
BIWhite="\[\033[1;97m\]" # White
7574

7675
# High Intensty backgrounds
77-
On_IBlack="\[\033[0;100m\]" # Black
78-
On_IRed="\[\033[0;101m\]" # Red
79-
On_IGreen="\[\033[0;102m\]" # Green
80-
On_IYellow="\[\033[0;103m\]" # Yellow
81-
On_IBlue="\[\033[0;104m\]" # Blue
82-
On_IPurple="\[\033[10;95m\]" # Purple
83-
On_ICyan="\[\033[0;106m\]" # Cyan
84-
On_IWhite="\[\033[0;107m\]" # White
85-
76+
On_IBlack="\[\033[0;100m\]" # Black
77+
On_IRed="\[\033[0;101m\]" # Red
78+
On_IGreen="\[\033[0;102m\]" # Green
79+
On_IYellow="\[\033[0;103m\]" # Yellow
80+
On_IBlue="\[\033[0;104m\]" # Blue
81+
On_IPurple="\[\033[10;95m\]" # Purple
82+
On_ICyan="\[\033[0;106m\]" # Cyan
83+
On_IWhite="\[\033[0;107m\]" # White
8684

8785
# Various variables you might want for your PS1 prompt instead
8886
Time12h="\T"
@@ -94,14 +92,14 @@ PathFull="\w"
9492
NewLine="\n"
9593
Jobs="\j"
9694

97-
9895
# This PS1 snippet was adopted from code for MAC/BSD I saw from: http://allancraig.net/index.php?option=com_content&view=article&id=108:ps1-export-command-for-git&catid=45:general&Itemid=96
9996
# I tweaked it to work on UBUNTU 11.04 & 11.10 plus made it mo' better
10097

10198
MyPS1=$Blue027$Username$IPurple@$IGreen$ShortHost$Color_Off'$(git branch &>/dev/null;\
10299
if [ $? -eq 0 ]; then \
103100
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
104-
HEADREV=`git log --pretty=%h -n 1`;
101+
HEADREV=$(git log --pretty=%h -n 1 2>/dev/null || echo "no-commits")
102+
105103
echo "'$BWhite'|$HEADREV" | tr -d "\n"; \
106104
if [ "$?" -eq "0" ]; then \
107105
# @4 - Clean repository - nothing to commit

0 commit comments

Comments
 (0)