-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_prompt
51 lines (45 loc) · 1.12 KB
/
.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
45
46
47
48
49
50
51
PROMPT_COMMAND=build_prompt
check_success()
{
if [ "$?" -eq 0 ]; then
HIST_COLOR="$WHITE"
else
HIST_COLOR="$BOLD_RED"
fi
}
parse_git_description()
{
git describe 2> /dev/null | sed -e 's/\(.*\)/ \[\1\]/'
}
parse_git_branch()
{
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
build_prompt()
{
check_success
gitBranch=$(parse_git_branch)
if [ "$gitBranch" == " [(no branch)]" ]; then
export PS1="\n($HIST_COLOR\!$WHITE) $CYAN\t $ICON $MAUVE\u$BLACK $BLUE\w$YELLOW\$(parse_git_description)$BLACK\n\$ "
else
export PS1="\n($HIST_COLOR\!$WHITE) $CYAN\t $ICON $MAUVE\u$BLACK $BLUE\w$YELLOW\$(parse_git_branch)$BLACK\n\$ "
fi
}
# echo "define colors"
BLACK="\[\033[0m\]"
BOLD_BLACK="\[\033[1;30m\]"
RED="\[\033[0;31m\]"
BOLD_RED="\[\033[1;31m\]"
GREEN="\[\033[0;32m\]"
BOLD_GREEN="\[\033[1;32m\]"
YELLOW="\[\033[0;33m\]"
BOLD_YELLOW="\[\033[1;33m\]"
BLUE="\[\033[0;34m\]"
BOLD_BLUE="\[\033[1;34m\]"
MAUVE="\[\033[0;35m\]"
BOLD_MAUVE="\[\033[1;35m\]"
CYAN="\[\033[0;36m\]"
BOLD_CYAN="\[\033[1;36m\]"
WHITE="\[\033[0;37m\]"
DARK_GREEN="\[\033]0;\w\007\033[32m\]"
ICON="🔥"