-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpowerline.theme
440 lines (330 loc) · 17.5 KB
/
powerline.theme
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# shellcheck shell=bash
_lp_powerline_theme_activate() {
# Load default markers if not already defined
POWERLINE_HARD_DIVIDER=${POWERLINE_HARD_DIVIDER:-""} # U+E0B0
POWERLINE_SOFT_DIVIDER=${POWERLINE_SOFT_DIVIDER:-""} # U+E0B1
POWERLINE_VCS_MARKER=${POWERLINE_VCS_MARKER:-""} # U+E0A0
POWERLINE_SECURE_MARKER=${POWERLINE_SECURE_MARKER:-""} # U+E0A2
POWERLINE_ROOT_MARKER=${POWERLINE_ROOT_MARKER:-"#"}
POWERLINE_STASH_MARKER=${POWERLINE_STASH_MARKER:-"ST"}
POWERLINE_PYTHON_ENV_MARKER=${POWERLINE_PYTHON_ENV_MARKER:-"(e) "}
POWERLINE_SPACER=${POWERLINE_SPACER:-" "} # U+00A0 non-breaking space
# Load default colors if not already defined
POWERLINE_HOST_COLOR=( ${POWERLINE_HOST_COLOR[@]+"${POWERLINE_HOST_COLOR[@]}"} )
[[ ${#POWERLINE_HOST_COLOR[@]} == 0 ]] && POWERLINE_HOST_COLOR=(220 166 0 0 3 2)
POWERLINE_USER_COLOR=( ${POWERLINE_USER_COLOR[@]+"${POWERLINE_USER_COLOR[@]}"} )
[[ ${#POWERLINE_USER_COLOR[@]} == 0 ]] && POWERLINE_USER_COLOR=(231 31 1 0 7 6)
POWERLINE_PYTHON_ENV_COLOR=( ${POWERLINE_PYTHON_ENV_COLOR[@]+"${POWERLINE_PYTHON_ENV_COLOR[@]}"} )
[[ ${#POWERLINE_PYTHON_ENV_COLOR[@]} == 0 ]] && POWERLINE_PYTHON_ENV_COLOR=(231 74 0 0 7 4)
POWERLINE_PATH_COLOR=( ${POWERLINE_PATH_COLOR[@]+"${POWERLINE_PATH_COLOR[@]}"} )
[[ ${#POWERLINE_PATH_COLOR[@]} == 0 ]] && POWERLINE_PATH_COLOR=(250 240 0 0 7 0)
POWERLINE_PATH_SEPARATOR_COLOR=( ${POWERLINE_PATH_SEPARATOR_COLOR[@]+"${POWERLINE_PATH_SEPARATOR_COLOR[@]}"} )
[[ ${#POWERLINE_PATH_SEPARATOR_COLOR[@]} == 0 ]] && POWERLINE_PATH_SEPARATOR_COLOR=(245 240 0 0 7 0)
POWERLINE_PATH_LAST_COLOR=( ${POWERLINE_PATH_LAST_COLOR[@]+"${POWERLINE_PATH_LAST_COLOR[@]}"} )
[[ ${#POWERLINE_PATH_LAST_COLOR[@]} == 0 ]] && POWERLINE_PATH_LAST_COLOR=(252 240 1 0 7 0)
POWERLINE_PATH_VCS_COLOR=( ${POWERLINE_PATH_VCS_COLOR[@]+"${POWERLINE_PATH_VCS_COLOR[@]}"} )
[[ ${#POWERLINE_PATH_VCS_COLOR[@]} == 0 ]] && POWERLINE_PATH_VCS_COLOR=(147 240 1 0 4 0)
POWERLINE_PATH_SHORTENED_COLOR=( ${POWERLINE_PATH_SHORTENED_COLOR[@]+"${POWERLINE_PATH_SHORTENED_COLOR[@]}"} )
[[ ${#POWERLINE_PATH_SHORTENED_COLOR[@]} == 0 ]] && POWERLINE_PATH_SHORTENED_COLOR=(245 240 0 0 7 0)
POWERLINE_JOBS_COLOR=( ${POWERLINE_JOBS_COLOR[@]+"${POWERLINE_JOBS_COLOR[@]}"} )
[[ ${#POWERLINE_JOBS_COLOR[@]} == 0 ]] && POWERLINE_JOBS_COLOR=(220 166 0 0 3 2)
POWERLINE_VCS_CLEAN_COLOR=( ${POWERLINE_VCS_CLEAN_COLOR[@]+"${POWERLINE_VCS_CLEAN_COLOR[@]}"} )
[[ ${#POWERLINE_VCS_CLEAN_COLOR[@]} == 0 ]] && POWERLINE_VCS_CLEAN_COLOR=(250 236 0 0 7 0)
POWERLINE_VCS_DIRTY_COLOR=( ${POWERLINE_VCS_DIRTY_COLOR[@]+"${POWERLINE_VCS_DIRTY_COLOR[@]}"} )
[[ ${#POWERLINE_VCS_DIRTY_COLOR[@]} == 0 ]] && POWERLINE_VCS_DIRTY_COLOR=(220 236 0 0 3 0)
POWERLINE_VCS_STASH_COLOR=( ${POWERLINE_VCS_STASH_COLOR[@]+"${POWERLINE_VCS_STASH_COLOR[@]}"} )
[[ ${#POWERLINE_VCS_STASH_COLOR[@]} == 0 ]] && POWERLINE_VCS_STASH_COLOR=(220 236 0 0 3 0)
POWERLINE_ERROR_COLOR=( ${POWERLINE_ERROR_COLOR[@]+"${POWERLINE_ERROR_COLOR[@]}"} )
[[ ${#POWERLINE_ERROR_COLOR[@]} == 0 ]] && POWERLINE_ERROR_COLOR=(231 52 0 0 7 1)
__powerline_hostname_generate
__powerline_username_generate
}
__powerline_hostname_generate() {
_POWERLINE_HOSTNAME="" _POWERLINE_HOST_ICON=""
local lp_hostname lp_connection
if _lp_hostname; then
_POWERLINE_HOSTNAME=${lp_hostname}
case "$lp_connection" in
ssh) _POWERLINE_HOST_ICON="${POWERLINE_SECURE_MARKER} " ;;
su) _POWERLINE_HOST_ICON="${POWERLINE_ROOT_MARKER} " ;;
esac
fi
}
__powerline_username_generate() {
_POWERLINE_USERNAME=
local lp_username
if _lp_username; then
_POWERLINE_USERNAME=${lp_username}
fi
}
_lp_powerline_theme_directory() {
# Not all terminals support Powerline special characters in the title
local title=
title+=${lp_username_raw-}
title+="${lp_hostname_raw+@}${lp_hostname_raw-}"
local lp_path
__powerline_path_generate
[[ -n $title ]] && title+=":"
title+="${lp_path}"
# Include a trailing space to pad for the title command.
_lp_raw_title "$title "
}
_lp_powerline_theme_prompt() {
local powerline_sections first_section sub_section_format _lp_last_af_color _lp_last_ab_color
__powerline_section "${_POWERLINE_HOST_ICON}${_POWERLINE_HOSTNAME}" "${POWERLINE_HOST_COLOR[@]}"
__powerline_section "$_POWERLINE_USERNAME" "${POWERLINE_USER_COLOR[@]}"
local lp_python_env
if _lp_python_env; then
__powerline_section "${POWERLINE_PYTHON_ENV_MARKER}${lp_python_env}" "${POWERLINE_PYTHON_ENV_COLOR[@]}"
fi
__powerline_section "$_lp_powerline_path" "${POWERLINE_PATH_COLOR[@]}"
local lp_running_jobs lp_stopped_jobs
if _lp_jobcount; then
__powerline_section "$(( lp_running_jobs + lp_stopped_jobs ))" "${POWERLINE_JOBS_COLOR[@]}"
fi
# TODO render on left side
local lp_vcs_type lp_vcs_root
if _lp_find_vcs; then
local lp_vcs_branch lp_vcs_uncommitted_files lp_vcs_untracked_files
_lp_vcs_branch
if _lp_vcs_uncommitted_files || _lp_vcs_untracked_files; then
__powerline_section "${POWERLINE_VCS_MARKER} ${lp_vcs_branch}" "${POWERLINE_VCS_DIRTY_COLOR[@]}"
else
__powerline_section "${POWERLINE_VCS_MARKER} ${lp_vcs_branch}" "${POWERLINE_VCS_CLEAN_COLOR[@]}"
fi
local lp_vcs_stash_count
if _lp_vcs_stash_count; then
__powerline_sub_section_format -2
powerline_sections+="${sub_section_format}${POWERLINE_SOFT_DIVIDER}"
__powerline_section "${POWERLINE_STASH_MARKER} ${lp_vcs_stash_count}" "${POWERLINE_VCS_STASH_COLOR[@]}"
fi
fi
if _lp_error; then
__powerline_section "${lp_error}" "${POWERLINE_ERROR_COLOR[@]}"
fi
__powerline_end_terminator
PS1=${powerline_sections}
}
_lp_powerline_full_theme_activate() {
_lp_powerline_theme_activate
# Load default markers if not already defined
POWERLINE_AWS_PROFILE_MARKER=${POWERLINE_AWS_PROFILE_MARKER:-"AWS: "}
POWERLINE_CHROOT_MARKER=${POWERLINE_CHROOT_MARKER:-"chroot: "}
POWERLINE_KUBECONTEXT_MARKER=${POWERLINE_KUBECONTEXT_MARKER:-$LP_MARK_KUBECONTEXT}
POWERLINE_NODE_ENV_MARKER=${POWERLINE_NODE_ENV_MARKER:-"node: "}
POWERLINE_PROXY_MARKER=${POWERLINE_PROXY_MARKER:-"proxy: "}
POWERLINE_RUBY_ENV_MARKER=${POWERLINE_RUBY_ENV_MARKER:-"ruby: "}
POWERLINE_SOFTWARE_COLLECTION_MARKER=${POWERLINE_SOFTWARE_COLLECTION_MARKER:-"(sc) "}
POWERLINE_TERRAFORM_ENV_MARKER=${POWERLINE_TERRAFORM_ENV_MARKER:-"(tf) "}
# Load default colors if not already defined
POWERLINE_NEUTRAL_COLOR=( ${POWERLINE_NEUTRAL_COLOR[@]+"${POWERLINE_NEUTRAL_COLOR[@]}"} )
[[ ${#POWERLINE_NEUTRAL_COLOR[@]} == 0 ]] && POWERLINE_NEUTRAL_COLOR=(252 234 0 0 7 0)
POWERLINE_AWS_PROFILE_COLOR=( ${POWERLINE_AWS_PROFILE_COLOR[@]+"${POWERLINE_AWS_PROFILE_COLOR[@]}"} )
[[ ${#POWERLINE_AWS_PROFILE_COLOR[@]} == 0 ]] && POWERLINE_AWS_PROFILE_COLOR=(190 236 0 0 3 0)
POWERLINE_BATTERY_COLOR=( ${POWERLINE_BATTERY_COLOR[@]+"${POWERLINE_BATTERY_COLOR[@]}"} )
[[ ${#POWERLINE_BATTERY_COLOR[@]} == 0 ]] && POWERLINE_BATTERY_COLOR=(-1 238 0 0 -1 0)
POWERLINE_CHROOT_COLOR=( ${POWERLINE_CHROOT_COLOR[@]+"${POWERLINE_CHROOT_COLOR[@]}"} )
[[ ${#POWERLINE_CHROOT_COLOR[@]} == 0 ]] && POWERLINE_CHROOT_COLOR=(219 30 0 0 7 4)
POWERLINE_CONTAINER_COLOR=( ${POWERLINE_CONTAINER_COLOR[@]+"${POWERLINE_CONTAINER_COLOR[@]}"} )
[[ ${#POWERLINE_CONTAINER_COLOR[@]} == 0 ]] && POWERLINE_CONTAINER_COLOR=("${POWERLINE_NEUTRAL_COLOR[@]}")
POWERLINE_DIRSTACK_COLOR=( ${POWERLINE_DIRSTACK_COLOR[@]+"${POWERLINE_DIRSTACK_COLOR[@]}"} )
[[ ${#POWERLINE_DIRSTACK_COLOR[@]} == 0 ]] && POWERLINE_DIRSTACK_COLOR=("${POWERLINE_NEUTRAL_COLOR[@]}")
POWERLINE_KUBECONTEXT_COLOR=( ${POWERLINE_KUBECONTEXT_COLOR[@]+"${POWERLINE_KUBECONTEXT_COLOR[@]}"} )
[[ ${#POWERLINE_KUBECONTEXT_COLOR[@]} == 0 ]] && POWERLINE_KUBECONTEXT_COLOR=(231 74 0 0 7 4)
POWERLINE_LOAD_COLOR=( ${POWERLINE_LOAD_COLOR[@]+"${POWERLINE_LOAD_COLOR[@]}"} )
[[ ${#POWERLINE_LOAD_COLOR[@]} == 0 ]] && POWERLINE_LOAD_COLOR=(-1 148 0 0 -1 3)
POWERLINE_NODE_ENV_COLOR=( ${POWERLINE_NODE_ENV_COLOR[@]+"${POWERLINE_NODE_ENV_COLOR[@]}"} )
[[ ${#POWERLINE_NODE_ENV_COLOR[@]} == 0 ]] && POWERLINE_NODE_ENV_COLOR=("${POWERLINE_PYTHON_ENV_COLOR[@]}")
POWERLINE_PROXY_COLOR=( ${POWERLINE_PROXY_COLOR[@]+"${POWERLINE_PROXY_COLOR[@]}"} )
[[ ${#POWERLINE_PROXY_COLOR[@]} == 0 ]] && POWERLINE_PROXY_COLOR=(21 219 1 0 4 7)
POWERLINE_RUBY_ENV_COLOR=( ${POWERLINE_RUBY_ENV_COLOR[@]+"${POWERLINE_RUBY_ENV_COLOR[@]}"} )
[[ ${#POWERLINE_RUBY_ENV_COLOR[@]} == 0 ]] && POWERLINE_RUBY_ENV_COLOR=("${POWERLINE_PYTHON_ENV_COLOR[@]}")
POWERLINE_RUNTIME_COLOR=( ${POWERLINE_RUNTIME_COLOR[@]+"${POWERLINE_RUNTIME_COLOR[@]}"} )
[[ ${#POWERLINE_RUNTIME_COLOR[@]} == 0 ]] && POWERLINE_RUNTIME_COLOR=(226 17 0 0 3 4)
POWERLINE_SHLVL_COLOR=( ${POWERLINE_SHLVL_COLOR[@]+"${POWERLINE_SHLVL_COLOR[@]}"} )
[[ ${#POWERLINE_SHLVL_COLOR[@]} == 0 ]] && POWERLINE_SHLVL_COLOR=(231 58 0 0 7 2)
POWERLINE_SOFTWARE_COLLECTIONS_COLOR=( ${POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]+"${POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]}"} )
[[ ${#POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]} == 0 ]] && POWERLINE_SOFTWARE_COLLECTIONS_COLOR=(231 62 0 0 7 5)
POWERLINE_TEMPERATURE_COLOR=( ${POWERLINE_TEMPERATURE_COLOR[@]+"${POWERLINE_TEMPERATURE_COLOR[@]}"} )
[[ ${#POWERLINE_TEMPERATURE_COLOR[@]} == 0 ]] && POWERLINE_TEMPERATURE_COLOR=(-1 240 0 0 -1 0)
POWERLINE_TERRAFORM_ENV_COLOR=( ${POWERLINE_TERRAFORM_ENV_COLOR[@]+"${POWERLINE_TERRAFORM_ENV_COLOR[@]}"} )
[[ ${#POWERLINE_TERRAFORM_ENV_COLOR[@]} == 0 ]] && POWERLINE_TERRAFORM_ENV_COLOR=(231 182 0 0 7 4)
POWERLINE_TIME_COLOR=( ${POWERLINE_TIME_COLOR[@]+"${POWERLINE_TIME_COLOR[@]}"} )
[[ ${#POWERLINE_TIME_COLOR[@]} == 0 ]] && POWERLINE_TIME_COLOR=(33 17 0 0 5 4)
POWERLINE_WIFI_STRENGTH_COLOR=( ${POWERLINE_WIFI_STRENGTH_COLOR[@]+"${POWERLINE_WIFI_STRENGTH_COLOR[@]}"} )
[[ ${#POWERLINE_WIFI_STRENGTH_COLOR[@]} == 0 ]] && POWERLINE_WIFI_STRENGTH_COLOR=(-1 148 0 0 -1 3)
}
_lp_powerline_full_theme_directory() {
_lp_powerline_theme_directory
}
_lp_powerline_full_theme_prompt() {
local powerline_sections first_section _lp_last_af_color _lp_last_ab_color
__powerline_section "$LP_PS1_PREFIX" "${POWERLINE_NEUTRAL_COLOR[@]}"
local lp_time lp_analog_time
if _lp_time; then
__powerline_section "$lp_time" "${POWERLINE_TIME_COLOR[@]}"
elif _lp_analog_time; then
__powerline_section "$lp_analog_time" "${POWERLINE_TIME_COLOR[@]}"
fi
__powerline_battery_section
local lp_load_color
if _lp_load_color; then
__powerline_formatted_section "$lp_load_color" "${POWERLINE_LOAD_COLOR[@]}"
fi
local lp_temperature_color
if _lp_temperature_color; then
__powerline_formatted_section "$lp_temperature_color" "${POWERLINE_TEMPERATURE_COLOR[@]}"
fi
local lp_wifi_signal_strength_color
if _lp_wifi_signal_strength_color; then
__powerline_formatted_section "$lp_wifi_signal_strength_color" "${POWERLINE_WIFI_STRENGTH_COLOR[@]}"
fi
local lp_detached_sessions lp_running_jobs lp_stopped_jobs jobs_string=
if _lp_detached_sessions; then
jobs_string="${lp_detached_sessions}d"
fi
if _lp_jobcount; then
if (( lp_running_jobs > 0 )); then
[[ -n $jobs_string ]] && jobs_string+='/'
jobs_string+="${lp_running_jobs}&"
fi
if (( lp_stopped_jobs > 0 )); then
[[ -n $jobs_string ]] && jobs_string+='/'
jobs_string+="${lp_stopped_jobs}z"
fi
fi
__powerline_section "$jobs_string" "${POWERLINE_JOBS_COLOR[@]}"
__powerline_section "$_POWERLINE_USERNAME" "${POWERLINE_USER_COLOR[@]}"
__powerline_section "${_POWERLINE_HOST_ICON}${_POWERLINE_HOSTNAME}" "${POWERLINE_HOST_COLOR[@]}"
__powerline_section "$_lp_powerline_path" "${POWERLINE_PATH_COLOR[@]}"
if _lp_dirstack; then
__powerline_section "${LP_MARK_DIRSTACK}${lp_dirstack}" "${POWERLINE_DIRSTACK_COLOR[@]}"
fi
if _lp_shell_level; then
__powerline_section "${LP_MARK_SHLVL}${lp_shell_level}" "${POWERLINE_SHLVL_COLOR[@]}"
fi
local lp_chroot
if _lp_chroot; then
__powerline_section "${POWERLINE_CHROOT_MARKER}${lp_chroot}" "${POWERLINE_CHROOT_COLOR[@]}"
fi
local lp_software_collections
if _lp_software_collections; then
__powerline_section "${POWERLINE_SOFTWARE_COLLECTION_MARKER}${lp_software_collections}" "${POWERLINE_SOFTWARE_COLLECTIONS_COLOR[@]}"
fi
local lp_aws_profile
if _lp_aws_profile; then
__powerline_section "${POWERLINE_AWS_PROFILE_MARKER}${lp_aws_profile}" "${POWERLINE_AWS_PROFILE_COLOR[@]}"
fi
local lp_python_env
if _lp_python_env; then
__powerline_section "${POWERLINE_PYTHON_ENV_MARKER}${lp_python_env}" "${POWERLINE_PYTHON_ENV_COLOR[@]}"
fi
local lp_node_env
if _lp_node_env; then
__powerline_section "${POWERLINE_NODE_ENV_MARKER}${lp_node_env}" "${POWERLINE_NODE_ENV_COLOR[@]}"
fi
local lp_ruby_env
if _lp_ruby_env; then
__powerline_section "${POWERLINE_RUBY_ENV_MARKER}${lp_ruby_env}" "${POWERLINE_RUBY_ENV_COLOR[@]}"
fi
local lp_kubernetes_context
if _lp_kubernetes_context; then
__powerline_section "${POWERLINE_KUBECONTEXT_MARKER}${lp_kubernetes_context}" "${POWERLINE_KUBECONTEXT_COLOR[@]}"
fi
local lp_terraform_env
if _lp_terraform_env; then
__powerline_section "${POWERLINE_TERRAFORM_ENV_MARKER}${lp_terraform_env}" "${POWERLINE_TERRAFORM_ENV_COLOR[@]}"
fi
local lp_http_proxy
if _lp_http_proxy; then
__powerline_section "${POWERLINE_PROXY_MARKER}${lp_http_proxy}" "${POWERLINE_PROXY_COLOR[@]}"
fi
__powerline_vcs_section
if _lp_runtime_format; then
__powerline_section "${lp_runtime_format}" "${POWERLINE_RUNTIME_COLOR[@]}"
fi
if _lp_error; then
__powerline_section "${lp_error}" "${POWERLINE_ERROR_COLOR[@]}"
fi
__powerline_section "$LP_PS1_POSTFIX" "${POWERLINE_NEUTRAL_COLOR[@]}"
__powerline_end_terminator
PS1=$powerline_sections
}
__powerline_section() { # string, (color array)
local section_arrow lp_terminal_format string="${1-}"
shift
[[ -z $string ]] && return 1
__powerline_section_arrow "$@"
lp_terminal_format "$@"
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}${string}${POWERLINE_SPACER}"
}
# Same as __powerline_section(), but it resets formatting after the input string
__powerline_formatted_section() {
local section_arrow lp_terminal_format string="${1-}"
shift
[[ -z $string ]] && return 1
__powerline_section_arrow "$@"
lp_terminal_format "$@"
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}${string}${lp_terminal_format}${POWERLINE_SPACER}"
}
# Reset background for end of prompt
__powerline_end_terminator() {
# Always add a end terminator, even if nothing is before it
local first_section="true"
__powerline_section_arrow -1
lp_terminal_format -1
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}"
}
__powerline_section_arrow() { # _, background_color, _, _, _, fallback_background_color
if [[ -n ${first_section-} ]]; then
local lp_terminal_format
lp_terminal_format -3 "${2-}" 0 0 -1 "${6-}"
section_arrow="${lp_terminal_format}${POWERLINE_HARD_DIVIDER}"
else
first_section="true"
section_arrow=
fi
}
__powerline_sub_section_format() { # foreground_color, _, _, _, fallback_foreground_color
local lp_terminal_format
lp_terminal_format "${1-}" -2 0 0 "${5-}"
sub_section_format="${lp_terminal_format}"
}
# We don't want to generate the path every prompt, so create the full formatted
# path once for each dir.
__powerline_path_generate() {
local lp_terminal_format sub_section_format _lp_last_af_color _lp_last_ab_color
lp_terminal_format "${POWERLINE_PATH_COLOR[@]}"
local path_format="$lp_terminal_format"
__powerline_sub_section_format "${POWERLINE_PATH_SEPARATOR_COLOR[@]}"
local separator_format="$sub_section_format"
lp_terminal_format "${POWERLINE_PATH_SHORTENED_COLOR[@]}"
local shortened_format="$lp_terminal_format"
lp_terminal_format "${POWERLINE_PATH_VCS_COLOR[@]}"
local vcs_format="$lp_terminal_format"
lp_terminal_format "${POWERLINE_PATH_LAST_COLOR[@]}"
local last_dir_format="$lp_terminal_format"
local lp_path_format
_lp_path_format "$path_format" "$last_dir_format" "$vcs_format" "$shortened_format" \
"${POWERLINE_SPACER}${POWERLINE_SOFT_DIVIDER}${POWERLINE_SPACER}" "$separator_format"
_lp_powerline_path=${lp_path_format}
}
# Is this a dirty hack? Yes. Am I proud of it? Also yes.
__powerline_battery_section() {
local lp_battery_color NO_COL=''
if _lp_battery_color; then
__powerline_formatted_section "$lp_battery_color" "${POWERLINE_BATTERY_COLOR[@]}"
fi
}
__powerline_vcs_section() {
local lp_vcs_type lp_vcs_root
if _lp_find_vcs; then
local section_arrow lp_terminal_format
__powerline_section_arrow "${POWERLINE_VCS_CLEAN_COLOR[@]}"
lp_terminal_format "${POWERLINE_VCS_CLEAN_COLOR[@]}"
local lp_vcs_details_color NO_COL="$lp_terminal_format"
_lp_vcs_details_color
powerline_sections+="${section_arrow}${lp_terminal_format}${POWERLINE_SPACER}${lp_vcs_details_color}${POWERLINE_SPACER}"
fi
}
# vim: ft=sh et sts=4 sw=4 tw=120