-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
122 lines (111 loc) · 3.18 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Customized for the Solarized color scheme by Sean O'Neil
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
#if [[ 1 ]]; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
# if [[ 0 ]] ; then
BASE03=$(tput setaf 234)
BASE02=$(tput setaf 235)
BASE01=$(tput setaf 240)
BASE00=$(tput setaf 241)
BASE0=$(tput setaf 244)
BASE1=$(tput setaf 245)
BASE2=$(tput setaf 254)
BASE3=$(tput setaf 230)
YELLOW=$(tput setaf 136)
ORANGE=$(tput setaf 166)
RED=$(tput setaf 160)
MAGENTA=$(tput setaf 125)
VIOLET=$(tput setaf 61)
BLUE=$(tput setaf 33)
CYAN=$(tput setaf 37)
GREEN=$(tput setaf 64)
PURPLE=$(tput setaf 125)
PINK=$(tput setaf 5)
else
BASE03=$(tput setaf 8)
BASE02=$(tput setaf 0)
BASE01=$(tput setaf 10)
BASE00=$(tput setaf 11)
BASE0=$(tput setaf 12)
BASE1=$(tput setaf 14)
BASE2=$(tput setaf 7)
BASE3=$(tput setaf 15)
YELLOW=$(tput setaf 3)
ORANGE=$(tput setaf 9)
RED=$(tput setaf 1)
MAGENTA=$(tput setaf 5)
VIOLET=$(tput setaf 13)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
GREEN=$(tput setaf 2)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
# Linux console colors. I don't have the energy
# to figure out the Solarized values
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
parse_git_status_column () {
git status --porcelain 2> /dev/null |cut -c$1|grep -c $2 |sed -E 's/^0$//; s/(.+)/ \1/'
}
parse_git_branch () {
git branch --no-color 2> /dev/null | grep '*' | sed "s/^* \(.*\)/\1/"
# git branch --no-color 2> /dev/null | grep '*' | sed "s/^*\(.*\)/\1$(parse_git_dirty)/"
}
parse_error () {
RET=$?
[[ $RET != 0 ]] && echo " ($RET)"
}
parse_virtual_env () {
[[ $VIRTUAL_ENV != '' ]] && echo "$(basename $VIRTUAL_ENV) "
}
#green=$(tput setaf 2)
green=$(tput setaf 64)
#blue=$(tput setaf 4)
blue=$(tput setaf 33)
#cyan=$(tput setaf 6)
cyan=$(tput setaf 37)
#orange=$(tput setaf 9)
orange=$(tput setaf 166)
#yellow=$(tput setaf 3)
yellow=$(tput setaf 136)
#violet=$(tput setaf 13)
violet=$(tput setaf 61)
#red=$(tput setaf 1)
red=$(tput setaf 160)
bold=$(tput bold)
reset=$(tput sgr0)
set_prommpt_vars() {
ERRMSG=$(parse_error) # must be first line of the prompt_command function
BRANCH=$(parse_git_branch)
STAGED=$(parse_git_status_column 1 [A-Z])
WORKING=$(parse_git_status_column 2 [A-Z])
UNTRACKED=$(parse_git_status_column 1,2 ?)
VIRT_ENV=$(parse_virtual_env)
}
set_ps1() {
PS1="\[$BOLD$CYAN\]$VIRT_ENV\[$YELLOW\]$BRANCH \[$BLUE\]$WORK_DIR_CHAR\[$GREEN\]$STAGED\[$ORANGE\]$WORKING\[$PINK\]$UNTRACKED\[$RED\]$ERRMSG \[$RESET\]\$ "
}
set_long_prompt() {
set_prommpt_vars
WORK_DIR_CHAR=\\w
set_ps1
}
set_short_prompt() {
set_prommpt_vars
WORK_DIR_CHAR=\\W
set_ps1
}
alias long_prompt='PROMPT_COMMAND=set_long_prompt'
alias short_prompt='PROMPT_COMMAND=set_short_prompt'
long_prompt