-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
44 lines (37 loc) · 836 Bytes
/
.bash_prompt
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
function git-branch-name
{
echo $(git branch | grep "^\*" | awk -F* {'print $NF'})
}
function git-dirty {
st=$(git status 2>/dev/null | tail -1)
if [[ $st != "nothing to commit, working tree clean" ]] ; then
echo "*"
fi
}
function git-unpushed {
brinfo=$(git status | grep ahead)
if [[ $brinfo =~ ([0-9]+)[[:space:]]commit ]] ; then
echo "(${BASH_REMATCH[1]})"
fi
}
function gitify {
git rev-parse --git-dir > /dev/null 2>&1
if [[ $? != 0 ]] ; then
echo ""
else
echo $(git-branch-name)$(git-dirty)$(git-unpushed)
fi
}
function make-prompt
{
local RED="\[\e[0;31m\]"
local GREEN="\[\e[0;32m\]"
local LIGHT_GRAY="\[\e[0;37m\]"
local CYAN="\[\e[0;36m\]"
PS1="\
${GREEN} \W\
${RED} \$(gitify)\
${GREEN}\
${LIGHT_GRAY} $ "
}
make-prompt