-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_prompt
265 lines (230 loc) · 7.27 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/env bash
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Configure & Customize The Prompt
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#
# - - - - - - - - - - - - - - - - - - - -
# Set The Terminal Color Scheme Type
# - - - - - - - - - - - - - - - - - - - -
#
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;
#
# - - - - - - - - - - - - - - - - - - - -
# Foreground Color Scheme
# - - - - - - - - - - - - - - - - - - - -
#
if tput setaf 1 &> /dev/null; then
tput sgr0;
bold=$(tput bold);
reset=$(tput sgr0);
fgBlack=$(tput setaf 16);
fgRed=$(tput setaf 203);
fgGreen=$(tput setaf 71);
fgYellow=$(tput setaf 226);
fgBlue=$(tput setaf 33);
fgMagenta=$(tput setaf 161);
fgCyan=$(tput setaf 38);
fgWhite=$(tput setaf 231);
fgPink=$(tput setaf 161);
fgPurple=$(tput setaf 127);
fgDeeppurple=$(tput setaf 55);
fgIndigo=$(tput setaf 25);
fgLightblue=$(tput setaf 39);
fgTeal=$(tput setaf 30);
fgLightgreen=$(tput setaf 112);
fgLime=$(tput setaf 184);
fgAmber=$(tput setaf 214);
fgOrange=$(tput setaf 208);
fgDeeporange=$(tput setaf 202);
fgBrown=$(tput setaf 94);
fgGray=$(tput setaf 102);
export bold reset fgBlack fgRed fgGreen fgYellow fgBlue fgMagenta fgCyan fgWhite fgPink fgPurple fgDeeppurple fgIndigo fgLightblue fgTeal fgLightgreen fgLime fgAmber fgOrange fgDeeporange fgBrown fgGray;
else
bold='';
reset="\e[0m";
fgDefault="\e[39m;"
fgBlack="\e[30m;"
fgRed="\e[31m;"
fgGreen="\e[32m;"
fgYellow="\e[33m;"
fgBlue="\e[34m;"
fgMagenta="\e[35m;"
fgCyan="\e[36m;"
fgDarkgray="\e[90m;"
fgLightgray="\e[37m;"
fgLightred="\e[91m;"
fgLightgreen="\e[92m;"
fgLightyellow="\e[93m;"
fgLightblue="\e[94m;"
fgLightmagenta="\e[95m;"
fgLightcyan="\e[96m;"
fgWhite="\e[97m;"
export bold reset fgDefault fgBlack fgRed fgGreen fgYellow fgBlue fgMagenta fgCyan fgDarkgray fgLightgray fgLightred fgLightgreen fgLightyellow fgLightblue fgLightmagenta fgLightcyan fgWhite;
fi;
#
# - - - - - - - - - - - - - - - - - - - -
# Background Color Scheme
# - - - - - - - - - - - - - - - - - - - -
#
if tput setab 1 &> /dev/null; then
tput sgr0;
bgBlack=$(tput setab 16);
bgRed=$(tput setab 203);
bgGreen=$(tput setab 71);
bgYellow=$(tput setab 226);
bgBlue=$(tput setab 33);
bgMagenta=$(tput setab 161);
bgCyan=$(tput setab 38);
bgWhite=$(tput setab 231);
bgPink=$(tput setab 161);
bgPurple=$(tput setab 127);
bgDeeppurple=$(tput setab 55);
bgIndigo=$(tput setab 25);
bgLightblue=$(tput setab 39);
bgTeal=$(tput setab 30);
bgLightgreen=$(tput setab 112);
bgLime=$(tput setab 184);
bgAmber=$(tput setab 214);
bgOrange=$(tput setab 208);
bgDeeporange=$(tput setab 202);
bgBrown=$(tput setab 94);
bgGray=$(tput setab 102);
export bgBlack bgRed bgGreen bgYellow bgBlue bgMagenta bgCyan bgWhite bgPink bgPurple bgDeeppurple bgIndigo bgLightblue bgTeal bgLightgreen bgLime bgAmber bgOrange bgDeeporange bgBrown bgGray;
else
bgDefault="\e[49m";
bgBlack="\e[40m";
bgRed="\e[41m";
bgGreen="\e[42m";
bgYellow="\e[43m";
bgBlue="\e[44m";
bgMagenta="\e[45m";
bgCyan="\e[46m";
bgDarkgray="\e[100m";
bgLightgray="\e[47m";
bgLightred="\e[101m";
bgLightgreen="\e[102m";
bgLightyellow="\e[103m";
bgLightblue="\e[104m";
bgLightmagenta="\e[105m";
bgLightcyan="\e[106m";
bgWhite="\e[107m";
export bgDefault bgBlack bgRed bgGreen bgYellow bgBlue bgMagenta bgCyan bgDarkgray bgLightgray bgLightred bgLightgreen bgLightyellow bgLightblue bgLightmagenta bgLightcyan bgWhite;
fi;
#
# - - - - - - - - - - - - - - - - - - - -
# Setup Git Prompt
# - - - - - - - - - - - - - - - - - - - -
#
prompt_git() {
local s='';
local branchName='';
# Check If The Current Directory Is In A Git Repository
if [ "$(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}")" == '0' ]; then
# Check If The Current Directory Is In .git Before Running Git Checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
# Ensure The Index Is Up To Date
git update-index --really-refresh -q &>/dev/null;
# Check For Uncommitted Changes In The Index
if ! git diff --quiet --ignore-submodules --cached; then
s+="${i_oct_plus} ";
fi;
# Check For Unstaged Changes
if ! git diff-files --quiet --ignore-submodules --; then
s+="${i_oct_zap} ";
fi;
# Check For Untracked Files
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+="${i_oct_x} ";
fi;
# Check For Stashed Files
if git rev-parse --verify refs/stash &>/dev/null; then
s+="${i_oct_squirrel} ";
fi;
fi;
# Get The Short Symbolic Ref
# If Head Isn’t A Symbolic Ref, Get The Short Sha For The Latest Commit
# Otherwise, Just Give Up
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";
[ -n "${s}" ] && s="[ ${s}]";
gitHubLogo="${i_oct_octoface} ";
echo -e " ${gitHubLogo}${1}${branchName} ${2}${s}";
else
return;
fi;
}
#
# - - - - - - - - - - - - - - - - - - - -
# Platform Dependent Prompt Symbols
# - - - - - - - - - - - - - - - - - - - -
#
if [[ -z "$PS_SYMBOL" ]]; then
case "$(uname)" in
Darwin) PS_SYMBOL="${i_dev_apple} ";;
Linux) PS_SYMBOL="${i_dev_linux} ";;
*) PS_SYMBOL="${i_dev_windows} ";;
esac
fi
#
# - - - - - - - - - - - - - - - - - - - -
# Highlight The User Name When Logged In As Root
# - - - - - - - - - - - - - - - - - - - -
#
if [[ "${USER}" == "root" ]]; then
userStyle="${bold}${fgRed}";
export userStyle;
else
userStyle="${bold}${fgOrange}";
export userStyle;
fi;
#
# - - - - - - - - - - - - - - - - - - - -
# Highlight The Hostname When Connected Via Ssh
# - - - - - - - - - - - - - - - - - - - -
#
if [[ "${SSH_TTY}" ]]; then
hostStyle="${bold}${fgRed}";
export hostStyle;
else
hostStyle="${fgYellow}";
export hostStyle;
fi;
#
# - - - - - - - - - - - - - - - - - - - -
# Customize The Left-Side Of The Bash Prompt
# - - - - - - - - - - - - - - - - - - - -
#
# Set The Terminal Title To The Current Working Directory
PS1="\[\033]0;\w\007\]";
# New Line
#PS1+="\n";
# Username
#PS1+="\[${userStyle}\]\u";
#PS1+="\[${white}\]@";
# Host
#PS1+="\[${hostStyle}\]\h";
#PS1+="\[${white}\] in ";
# Working Directory
PS1+="\[${bgLightblue}${fgBlack}\] ${i_mdi_folder_open} ~/\W ";
# Git Repository Details
PS1+="\[${bgGreen}\]\$(prompt_git \" ${i_oct_git_branch} \" \"\")\[${reset}\]";
PS1+="\n";
# OS Symbol
PS1+="\[${fgGreen}\] ${PS_SYMBOL}\[${reset}\]";
export PS1;
#
# - - - - - - - - - - - - - - - - - - - -
# Customize The Right-Side Of The Bash Prompt
# - - - - - - - - - - - - - - - - - - - -
#
PS2="\[${fgYellow}\]→ \[${reset}\]";
export PS2;