-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_prompt
68 lines (58 loc) · 1.38 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /usr/bin/env bash
## Colors? Used for the prompt.
#Regular text color
BLACK='\[\e[0;30m\]'
#Bold text color
BBLACK='\[\e[1;30m\]'
#background color
BGBLACK='\[\e[40m\]'
RED='\[\e[0;31m\]'
BRED='\[\e[1;31m\]'
BGRED='\[\e[41m\]'
GREEN='\[\e[0;32m\]'
BGREEN='\[\e[1;32m\]'
BGGREEN='\[\e[1;32m\]'
YELLOW='\[\e[0;33m\]'
BYELLOW='\[\e[1;33m\]'
BGYELLOW='\[\e[1;33m\]'
BLUE='\[\e[0;34m\]'
BBLUE='\[\e[1;34m\]'
BGBLUE='\[\e[1;34m\]'
MAGENTA='\[\e[0;35m\]'
BMAGENTA='\[\e[1;35m\]'
BGMAGENTA='\[\e[1;35m\]'
CYAN='\[\e[0;36m\]'
BCYAN='\[\e[1;36m\]'
BGCYAN='\[\e[1;36m\]'
WHITE='\[\e[0;37m\]'
BWHITE='\[\e[1;37m\]'
BGWHITE='\[\e[1;37m\]'
PROMPT_COMMAND=prompt
function get_git_branch_prompt {
local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
local diff_stat=$(git status --porcelain 2>/dev/null)
local diff_working_stat=$(git diff --stat 2>/dev/null)
local mod_color="\e[1;32m"
local modifier=""
if [ "$diff_stat" != "" ]; then
mod_color="\e[1;31m"
fi
if [ "$diff_working_stat" != "" ]; then
modifier="*"
fi
if [ "$branch" != "" ]; then
echo -e " \e[1;36m(${mod_color}${branch}${modifier}\e[1;36m)"
fi
}
function prompt {
PS1=""
if [ $UID -eq 0 ]; then
#root user color
UC="${RED}"
PS1="${RED}root "
fi
DF='\[\e[0m\]'
BRANCH='$(get_git_branch_prompt)'
BRANCH_STATUS='$(get_branch_status_line)'
PS1="$PS1${CYAN}\W$BRANCH ${BYELLOW}\$${DF} "
}