forked from rockwood/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
38 lines (33 loc) · 990 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
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
export RED="\033[0;91m"
export GREEN="\033[0;92m"
export YELLOW="\033[0;93m"
export BLUE="\033[0;94m"
export PURPLE="\033[0;95m"
export CYAN="\033[0;96m"
export WHITE="\033[0;97m"
export GREY="\033[0;m"
export RESET="\033[0m"
function git_status_color() {
if [[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]]; then
echo $RED
else
echo $GREEN
fi
}
function git_branch() {
echo $(git branch --no-color 2> /dev/null | grep '*' | sed 's/\*//g' | sed 's/ //g')
}
function set_prompt() {
local branch=$(git_branch)
local prompt="\[$WHITE\][\[$BLUE\]\w\[$WHITE\]]"
if [ $branch ]; then
prompt="$prompt\[$WHITE\][\[$(git_status_color)\]$branch\[$WHITE\]]"
fi
export PS1="$prompt \[$WHITE\]» \[$RESET\]"
}
PROMPT_COMMAND=set_prompt