-
Notifications
You must be signed in to change notification settings - Fork 3
/
jolly.theme
1415 lines (1198 loc) · 52.3 KB
/
jolly.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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
########################################################################
# API
########################################################################
_lp_jolly_theme_activate() {
if ! _lp_version_greatereq 2 2 0 ; then
_lp_join "." ${_LP_VERSION[@]}
printf "WARNING: the Jolly theme requires Liquid Prompt >= 2.2.0, but you have version $lp_join, some features will not work and the prompt may crash.\n"
fi
LP_ENABLE_VCS_DIFFSTATS=${LP_ENABLE_VCS_DIFFSTATS:-1}
_LP_LOAD_THRESHOLD=${_LP_LOAD_THRESHOLD:-80}
_LP_LOAD_CAP=${_LP_LOAD_CAP:-100}
JOLLY_DISPLAY_TEXT=${JOLLY_DISPLAY_TEXT:-"T"}
JOLLY_DISPLAY_X11=${JOLLY_DISPLAY_X11:-"X"}
JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-"⌂"}
JOLLY_MARK_STASH=${JOLLY_MARK_STASH:-"✝"}
JOLLY_MARK_UNTRACKED=${JOLLY_MARK_UNTRACKED:-"?"} # ⛶
JOLLY_DIFF=${JOLLY_DIFF:-"≠"}
JOLLY_ENABLE_GRADIENT_LINE=${JOLLY_ENABLE_GRADIENT_LINE:-0}
JOLLY_ENABLE_SHELL=${JOLLY_ENABLE_SHELL:-0}
JOLLY_SHELL_ZSH=${JOLLY_SHELL_ZSH:-"z"}
JOLLY_SHELL_BASH=${JOLLY_SHELL_BASH:-"b"}
JOLLY_VCS_REMOTE_ORIGIN=${JOLLY_VCS_REMOTE_ORIGIN:-"🖈"}
JOLLY_ENABLE_HISTORY=${JOLLY_ENABLE_HISTORY:-0}
JOLLY_HISTORY_LAST_LEN=${JOLLY_HISTORY_LAST_LEN:-$((COLUMNS/4))}
JOLLY_HISTORY_LAST_LEN_MARK=${JOLLY_HISTORY_LAST_LEN_MARK:-"[…]"}
JOLLY_HISTORY_MOST_BACK=${JOLLY_HISTORY_MOST_BACK:-100}
# Thresholds based on 75th quantile for:
# nb of commits in PR on Github and added+removed lines.
# See: https://promyze.com/observations-on-10000-pull-requests-on-github/
JOLLY_VCS_AHEAD_THRESHOLD=${JOLLY_VCS_AHEAD_THRESHOLD:-5}
JOLLY_VCS_BEHIND_THRESHOLD=${JOLLY_VCS_BEHIND_THRESHOLD:-5}
JOLLY_VCS_DIFF_THRESHOLD=${JOLLY_VCS_DIFF_THRESHOLD:-300}
JOLLY_DETACHED_THRESHOLD=${JOLLY_DETACHED_THRESHOLD:-3}
JOLLY_RUNNING_THRESHOLD=${JOLLY_RUNNING_THRESHOLD:-3}
JOLLY_STOPPED_THRESHOLD=${JOLLY_STOPPED_THRESHOLD:-3}
JOLLY_BATTERY_THRESHOLD=${JOLLY_BATTERY_THRESHOLD:-$((LP_BATTERY_THRESHOLD/2))}
JOLLY_RAM_THRESHOLD=${JOLLY_RAM_THRESHOLD:-$((LP_RAM_THRESHOLD/2))}
JOLLY_DISK_THRESHOLD=${JOLLY_DISK_THRESHOLD:-$((LP_DISK_THRESHOLD/2))}
JOLLY_TEMP_THRESHOLD=${JOLLY_TEMP_THRESHOLD:-$((LP_TEMP_THRESHOLD*2))}
# Use prefixed _LP_* variables, which are integers.
JOLLY_LOAD_THRESHOLD=${JOLLY_LOAD_THRESHOLD:-$((_LP_LOAD_THRESHOLD+(_LP_LOAD_CAP-_LP_LOAD_THRESHOLD)/2))}
JOLLY_MARK_ERROR=${JOLLY_MARK_ERROR:-""}
# Sets of characters
# "dotmatrix" variant by default (non-patched font)
JOLLY_HOST_LOCAL=${JOLLY_HOST_LOCAL:-"⌂"}
JOLLY_USER_LOCAL=${JOLLY_USER_LOCAL:-"♟"}
JOLLY_VCS=${JOLLY_VCS:-"╟┘"}
JOLLY_MARK=${JOLLY_MARK:-"⯀"}
JOLLY_MARK_SUDO=${JOLLY_MARK_SUDO:-"⋮"}
JOLLY_LINE=${JOLLY_LINE:-"━"}
JOLLY_PLUG=${JOLLY_PLUG:-"▛"}
JOLLY_SOFT=${JOLLY_SOFT:-"╱"}
JOLLY_MEAN=${JOLLY_MEAN:-"▞"}
# Separator arrays (left center right)
JOLLY_LINK=( ${JOLLY_LINK[@]+"${JOLLY_LINK[@]}"} )
[[ ${#JOLLY_LINK[@]} == 0 ]] && JOLLY_LINK=("▙" " " "▜")
JOLLY_LINK_R=( ${JOLLY_LINK_R[@]+"${JOLLY_LINK_R[@]}"} )
[[ ${#JOLLY_LINK_R[@]} == 0 ]] && JOLLY_LINK_R=("▛" " " "▟")
JOLLY_OPEN=( ${JOLLY_OPEN[@]+"${JOLLY_OPEN[@]}"} )
[[ ${#JOLLY_OPEN[@]} == 0 ]] && JOLLY_OPEN=("▙" " ▚ " "▜")
JOLLY_DANG=( ${JOLLY_DANG[@]+"${JOLLY_DANG[@]}"} )
[[ ${#JOLLY_DANG[@]} == 0 ]] && JOLLY_DANG=("▙" " □ " "▜")
JOLLY_ENDS=( ${JOLLY_ENDS[@]+"${JOLLY_ENDS[@]}"} )
[[ ${#JOLLY_ENDS[@]} == 0 ]] && JOLLY_ENDS=("▛" "▞▗ ▝" "▖ ▘▞▟")
JOLLY_ITEMS=( ${JOLLY_ITEMS[@]+"${JOLLY_ITEMS[@]}"} )
[[ ${#JOLLY_ITEMS[@]} == 0 ]] && JOLLY_ITEMS=("┫" "┃" "┣")
JOLLY_SPACED=${JOLLY_SPACED:-1}
# Number of spaces to add
if [[ ${JOLLY_SPACED} == 0 ]] ; then
JOLLY_SPACE_VOID=""
JOLLY_SPACE_FILL=""
JOLLY_SPACE_PATH=${JOLLY_SPACE_PATH:-""}
JOLLY_SPACE_FIELD=${JOLLY_SPACE_FIELD:-""}
JOLLY_SPACE_LINE=${JOLLY_SPACE_LINE:-""}
elif [[ ${JOLLY_SPACED} == 1 ]] ; then
JOLLY_SPACE_VOID=" "
JOLLY_SPACE_FILL="█"
JOLLY_SPACE_PATH=${JOLLY_SPACE_PATH:-" "}
JOLLY_SPACE_FIELD=${JOLLY_SPACE_FIELD:-""}
JOLLY_SPACE_LINE=${JOLLY_SPACE_LINE:-" "}
else
local n="${JOLLY_SPACED:-1}"
[[ $n -lt 0 ]] && n=1
local i
JOLLY_SPACE_VOID=""
JOLLY_SPACE_FILL=""
for ((i=0; i < n; i++)); do
JOLLY_SPACE_VOID+=" " # Regular space
JOLLY_SPACE_FILL+="█" # Inverted space
done
JOLLY_SPACE_PATH=${JOLLY_SPACE_PATH:-"${JOLLY_SPACE_VOID}"}
JOLLY_SPACE_FIELD=${JOLLY_SPACE_FIELD:-""}
JOLLY_SPACE_LINE=${JOLLY_SPACE_LINE:-""}
fi
# Color arrays defaults fg bg b u ffg fbg
JOLLY_COLOR_DARK=( ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"} )
[[ ${#JOLLY_COLOR_DARK[@]} == 0 ]] && JOLLY_COLOR_DARK=(252 239 0 0 15 0)
JOLLY_COLOR_LITE=( ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"} )
[[ ${#JOLLY_COLOR_LITE[@]} == 0 ]] && JOLLY_COLOR_LITE=(239 252 0 0 0 15)
JOLLY_COLOR_GLOW=( ${JOLLY_COLOR_GLOW[@]+"${JOLLY_COLOR_GLOW[@]}"} )
[[ ${#JOLLY_COLOR_GLOW[@]} == 0 ]] && JOLLY_COLOR_GLOW=( 255 239 1 0 0 15)
JOLLY_COLOR_NOTE=( ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"} )
[[ ${#JOLLY_COLOR_NOTE[@]} == 0 ]] && JOLLY_COLOR_NOTE=( 15 33 0 0 15 12)
JOLLY_COLOR_WARN=( ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"} )
[[ ${#JOLLY_COLOR_WARN[@]} == 0 ]] && JOLLY_COLOR_WARN=(196 220 1 0 0 11)
JOLLY_COLOR_FAIR=( ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"} )
[[ ${#JOLLY_COLOR_FAIR[@]} == 0 ]] && JOLLY_COLOR_FAIR=( 0 239 1 0 0 8)
JOLLY_COLOR_PATH_SHORT=( ${JOLLY_COLOR_PATH_SHORT[@]+"${JOLLY_COLOR_PATH_SHORT[@]}"} )
[[ ${#JOLLY_COLOR_PATH_SHORT[@]} == 0 ]] && JOLLY_COLOR_PATH_SHORT=(252 239 0 0 0 15)
JOLLY_COLOR_PATH_VCS=( ${JOLLY_COLOR_PATH_VCS[@]+"${JOLLY_COLOR_PATH_VCS[@]}"} )
[[ ${#JOLLY_COLOR_PATH_VCS[@]} == 0 ]] && JOLLY_COLOR_PATH_VCS=(252 239 0 1 0 15)
JOLLY_COLOR_PATH_LAST=( ${JOLLY_COLOR_PATH_LAST[@]+"${JOLLY_COLOR_PATH_LAST[@]}"} )
[[ ${#JOLLY_COLOR_PATH_LAST[@]} == 0 ]] && JOLLY_COLOR_PATH_LAST=(15 239 1 0 0 15)
JOLLY_COLOR_LINE=( ${JOLLY_COLOR_LINE[@]+"${JOLLY_COLOR_LINE[@]}"} )
[[ ${#JOLLY_COLOR_LINE[@]} == 0 ]] && JOLLY_COLOR_LINE=(244 -1 0 0 15 -1)
JOLLY_COLOR_LINE_START=( ${JOLLY_COLOR_LINE_START[@]+"${JOLLY_COLOR_LINE_START[@]}"} )
[[ ${#JOLLY_COLOR_LINE_START[@]} == 0 ]] && JOLLY_COLOR_LINE_START=(255 -1 1 0 15 -1)
JOLLY_COLOR_LINE_END=( ${JOLLY_COLOR_LINE_END[@]+"${JOLLY_COLOR_LINE_END[@]}"} )
[[ ${#JOLLY_COLOR_LINE_END[@]} == 0 ]] && JOLLY_COLOR_LINE_END=(232 -1 1 0 15 -1)
JOLLY_COLOR_MARK=( ${JOLLY_COLOR_MARK[@]+"${JOLLY_COLOR_MARK[@]}"} )
[[ ${#JOLLY_COLOR_MARK[@]} == 0 ]] && JOLLY_COLOR_MARK=(15 -1 0 0 15 -1)
JOLLY_COLOR_SEP_DARK=( ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"} )
[[ ${#JOLLY_COLOR_SEP_DARK[@]} == 0 ]] && JOLLY_COLOR_SEP_DARK=( 0 -2 0 0 0 -2)
JOLLY_COLOR_SEP_FAIR=( ${JOLLY_COLOR_SEP_FAIR[@]+"${JOLLY_COLOR_SEP_FAIR[@]}"} )
[[ ${#JOLLY_COLOR_SEP_FAIR[@]} == 0 ]] && JOLLY_COLOR_SEP_FAIR=(244 -2 0 0 0 -2)
JOLLY_COLOR_SEP_LITE=( ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"} )
[[ ${#JOLLY_COLOR_SEP_LITE[@]} == 0 ]] && JOLLY_COLOR_SEP_LITE=( 15 -2 0 0 15 -2)
# Default line color for unset variables.
LP_COLOR_ENV_VARS_UNSET=${LP_COLOR_ENV_VARS_UNSET:-""}
# Use the background of notes as a foreground for set variables.
lp_terminal_format "${JOLLY_COLOR_NOTE[1]}"
LP_COLOR_ENV_VARS_SET=${LP_COLOR_ENV_VARS_SET:-"$lp_terminal_format"}
# LP_COLORMAP=( ${LP_COLORMAP[@]+"${LP_COLORMAP[@]}"} )
# if [[ ${#LP_COLORMAP[@]} == 0 ]]; then
local lp_terminal_format
lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
local l1="$lp_terminal_format"
lp_terminal_format ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
local l2="$lp_terminal_format"
lp_terminal_format ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
local l3="$lp_terminal_format"
LP_COLORMAP=(
"" # l0
"$l1"
"$l2"
"$l3"
)
# fi
__jolly_activate_display
# __jolly_activate_shell
__jolly_activate_connection
__jolly_activate_user
__jolly_activate_multiplexer
__jolly_activate_hostname
}
_lp_jolly_theme_directory() {
lp_terminal_format ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
__jolly_directory_FS
__jolly_directory_path
}
_lp_jolly_make_header() {
# Arguments: fg, bg, bold, underline, fallback_fg, fallback_bg
# Color codes can be any integer in 256 XTerm's system colors in [0–255].
# Special color codes:
# -1 : no color
# -2 : previously set color
# -3 : swap fg and bg
local lp_terminal_format
####################################################################
# HEADER (LEFT)
####################################################################
_lp_jolly_make_header=""
_lp_jolly_make_header+="${_JOLLY_DISPLAY}"
_lp_jolly_make_header+="${_JOLLY_CONNECTION}"
_lp_jolly_make_header+="${_JOLLY_USER}"
_lp_jolly_make_header+="${_JOLLY_MULTIPLEXER}"
_lp_jolly_make_header+="${_JOLLY_HOSTNAME}"
_lp_jolly_make_header+="${_JOLLY_FS}"
_lp_jolly_make_header+="${_JOLLY_PATH} "
if _lp_dirstack; then
# Pseudo-recall the path section format.
lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
__jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_lp_jolly_make_header+="${jolly_sep}"
__jolly_make_field "$lp_dirstack" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_lp_jolly_make_header+="${jolly_field}"
fi
}
_lp_jolly_make_side() {
####################################################################
# HEADER SIDE (RIGHT)
####################################################################
local _lp_jolly_has_notes=0
local _lp_jolly_has_warns=0
# JOLLY_COLOR_SEP_FAIR
__jolly_make_sep_side ""
_lp_jolly_make_side="${jolly_sep}"
# battery / load / temperature
local battery=
if _lp_battery_color ; then
if [[ $lp_battery -le "$JOLLY_BATTERY_THRESHOLD" ]]; then
__jolly_make_field "$lp_battery$_LP_PERCENT" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
battery="${jolly_field}${LP_MARK_BATTERY}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "$lp_battery$_LP_PERCENT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
battery="${jolly_field}${LP_MARK_BATTERY}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
local load=
if _lp_load_color ; then
if [[ $lp_load_adjusted -ge "$JOLLY_LOAD_THRESHOLD" ]]; then
__jolly_make_field "$lp_load" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
load="${jolly_field}${LP_MARK_LOAD}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "$lp_load" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
load="${jolly_field}${LP_MARK_LOAD}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
local ram=
if _lp_ram_color ; then
if [[ $lp_ram_perc -le "$JOLLY_RAM_THRESHOLD" ]]; then
__jolly_make_field "$lp_ram_perc$_LP_PERCENT" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
ram="${jolly_field}${LP_MARK_RAM}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "$lp_ram_perc$_LP_PERCENT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
ram="${jolly_field}${LP_MARK_RAM}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
local disk=
if _lp_disk_color ; then
if [[ $lp_disk_perc -le "$JOLLY_DISK_THRESHOLD" ]]; then
__jolly_make_field "$lp_disk_perc$_LP_PERCENT" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
disk="${jolly_field}${LP_MARK_DISK}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "$lp_disk_perc$_LP_PERCENT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
disk="${jolly_field}${LP_MARK_DISK}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
local temperature=
if _lp_temperature_color ; then
if [[ $lp_temperature -ge "$JOLLY_TEMP_THRESHOLD" ]]; then
__jolly_make_field "$lp_temperature" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
temperature="${jolly_field}${LP_MARK_TEMP}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "$lp_temperature" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
temperature="${jolly_field}${LP_MARK_TEMP}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
__jolly_make_sep_soft ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"}
declare -a blt=($battery $load $ram $disk $temperature) # Unquoted on purpose.
if [[ ${#blt[@]} -gt 0 ]] ; then
_lp_join "$jolly_sep" ${blt[@]}
if [[ -n "$lp_join" ]] ; then
# Match the side sep
local fg="${JOLLY_COLOR_SEP_FAIR[0]}"
local ffg="${JOLLY_COLOR_SEP_FAIR[4]}"
lp_terminal_format "$fg" -2 0 0 "$ffg" -2
# No space before sep.
_lp_jolly_make_side+="${lp_terminal_format}${JOLLY_SPACE_VOID}${lp_join}"
fi
else
lp_terminal_format ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"}
_lp_jolly_make_side+="${lp_terminal_format}"
fi
# jobs: detached / running / stopped
local detached_sessions=
if _lp_detached_sessions ; then
if [[ -n "${lp_detached_sessions}" && "${lp_detached_sessions}" -gt 0 ]] ; then
if [[ "${lp_detached_sessions}" -ge "${JOLLY_DETACHED_THRESHOLD}" ]]; then
__jolly_make_field "${lp_detached_sessions}d" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
detached_sessions="${jolly_field}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "${lp_detached_sessions}d" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
detached_sessions="${jolly_field}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
fi
local running_jobs=
local stopped_jobs=
if _lp_jobcount ; then
if [[ -n "${lp_running_jobs}" && "${lp_running_jobs}" -gt 0 ]] ; then
if [[ "${lp_running_jobs}" -ge "${JOLLY_RUNNING_THRESHOLD}" ]]; then
__jolly_make_field "${lp_running_jobs}&" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
running_jobs="${jolly_field}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "${lp_running_jobs}&" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
running_jobs="${jolly_field}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
if [[ -n "${lp_stopped_jobs}" && "${lp_stopped_jobs}" -gt 0 ]] ; then
if [[ "${lp_stopped_jobs}" -ge "${JOLLY_STOPPED_THRESHOLD}" ]]; then
__jolly_make_field "${lp_stopped_jobs}z" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
stopped_jobs="${jolly_field}"
_lp_jolly_has_warns=$((_lp_jolly_has_warns+1))
else
__jolly_make_field "${lp_stopped_jobs}z" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
stopped_jobs="${jolly_field}"
_lp_jolly_has_notes=$((_lp_jolly_has_notes+1))
fi
fi
fi
lp_terminal_format ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"}
if [[ $_lp_jolly_has_warns -gt 0 ]]; then
__jolly_make_sep_plug ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
else
__jolly_make_sep_plug ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
fi
local djc_plug="${jolly_sep}"
__jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"}
declare -a drs=($detached_sessions $running_jobs $stopped_jobs) # Unquoted on purpose.
if [[ ${#drs[@]} -gt 0 ]] ; then
_lp_join "$jolly_sep" "${drs[@]}"
if [[ -n "$lp_join" ]] ; then
_lp_jolly_make_side+="${djc_plug}${lp_join}"
fi
else
lp_terminal_format ${JOLLY_COLOR_FAIR[@]+"${JOLLY_COLOR_FAIR[@]}"}
_lp_jolly_make_side+="${lp_terminal_format}"
fi
# Called here for an easy access to the configured color.
if __jolly_activate_shell ; then
_lp_jolly_make_side+="${_JOLLY_SHELL}"
fi
# clock
if _lp_time ; then
__jolly_make_sep_plug ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_lp_jolly_make_side+="${jolly_sep}"
if _lp_analog_time ; then
__jolly_make_field "$lp_analog_time" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_lp_jolly_make_side+="$jolly_field"
else
__jolly_make_field "$lp_time" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_lp_jolly_make_side+="$jolly_field"
fi
fi
}
_lp_jolly_make_env() {
####################################################################
# IN LINE
####################################################################
local color_line_end=""
if (( LP_ENABLE_SSH_COLORS )); then
local lp_hostname_hash
__lp_hostname_hash
__lp_foreground_color "$(( 1 + lp_hostname_hash % 6 ))"
color_line_end="${_LP_OPEN_ESC}${af_color}${_LP_CLOSE_ESC}"
fi
lp_terminal_format ${JOLLY_COLOR_LINE[@]+"${JOLLY_COLOR_LINE[@]}"}
color_line_start="$lp_terminal_format"
_lp_jolly_make_env_inline_left="${NO_COL}$LP_PS1_PREFIX${lp_terminal_format}${JOLLY_LINE}"
# Dev env section.
local ista="$_LP_FIRST_INDEX"
local imid=$((_LP_FIRST_INDEX+1))
local iend=$((_LP_FIRST_INDEX+2))
local d="${color_line_start}${JOLLY_ITEMS[ista]}${JOLLY_SPACE_LINE}"
local I="${color_line_start}${JOLLY_SPACE_LINE}${JOLLY_ITEMS[imid]}${JOLLY_SPACE_LINE}"
local b="${color_line_start}${JOLLY_SPACE_LINE}${JOLLY_ITEMS[iend]}${color_line_end}"
if _lp_env_vars "${LP_COLOR_ENV_VARS_SET}" "${LP_COLOR_ENV_VARS_UNSET}"; then
local lp_join
_lp_join "$I" ${lp_env_vars[@]}
_lp_jolly_make_env_inline_left+="$d${lp_join}$b"
fi
if _lp_software_collections ; then
_lp_jolly_make_env_inline_left+="$d${lp_software_collections}$b"
fi
if _lp_python_env ; then
_lp_jolly_make_env_inline_left+="$d${lp_python_env}$b"
fi
if _lp_node_env ; then
_lp_jolly_make_env_inline_left+="$d${lp_node_env}$b"
fi
if _lp_ruby_env ; then
_lp_jolly_make_env_inline_left+="$d${lp_ruby_env}$b"
fi
if _lp_container ; then
_lp_jolly_make_env_inline_left+="$d${lp_container}$b"
fi
if _lp_kubernetes_context ; then
_lp_jolly_make_env_inline_left+="$d${lp_kubernetes_context}$b"
fi
if _lp_terraform_env ; then
_lp_jolly_make_env_inline_left+="$d${lp_terraform_env}$b"
fi
if _lp_aws_profile ; then
_lp_jolly_make_env_inline_left+="$d${lp_aws_profile}$b"
fi
if _lp_cmake ; then
local lp_join
_lp_join "$I" ${lp_cmake_c_compiler} ${lp_cmake_cxx_compiler} ${lp_cmake_generator} ${lp_cmake_buildtype}
_lp_jolly_make_env_inline_left+="$d${lp_join}$b"
fi
if _lp_container; then
_lp_jolly_make_env_inline_left+="$d$lp_container$b"
fi
if _lp_modules; then
_lp_jolly_make_env_inline_left+="$d"
_lp_join "$I" "${lp_modules[@]}"
_lp_jolly_make_env_inline_left+="${lp_join}$b"
fi
# History section.
local _lp_jolly_make_env_inline_right=
if _lp_os; then
_lp_join "$I" ${lp_os_arch} ${lp_os_family} ${lp_os_kernel} ${lp_os_distrib} ${lp_os_version}
_lp_jolly_make_env_inline_right+="$d${lp_join}$b"
fi
if ((JOLLY_ENABLE_HISTORY)) ; then
local hist_max
hist_max=$((JOLLY_HISTORY_LAST_LEN-${#JOLLY_HISTORY_LAST_LEN_MARK}))
local hist_last
hist_last=$(history | tail -n 1 | cut -d" " -f5-)
if [[ ${#hist_last} -gt $hist_max ]] ; then
if (( _LP_SHELL_zsh )) ; then
hist_last="${hist_last[1,$hist_max]}${JOLLY_HISTORY_LAST_LEN_MARK}"
else # bash
hist_last="${hist_last:0:$hist_max}${JOLLY_HISTORY_LAST_LEN_MARK}"
fi
fi
local hist_most
hist_most=$(history | tail -n "${JOLLY_HISTORY_MOST_BACK}" | awk '{print $4}' | sort | uniq --count | sort --numeric-sort --reverse | head -n 1 | awk '{print $2}')
__lp_escape "$hist_last"
local hlast="$ret"
__lp_escape "$hist_most"
local hmost="$ret"
_lp_jolly_make_env_inline_right="$d${hlast}$I${hmost}$b"
fi
}
_lp_jolly_make_vcs() {
_lp_jolly_make_vcs=""
lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
if (( LP_ENABLE_WIFI_STRENGTH )) ; then
if _lp_wifi_signal_strength ; then
lp_terminal_format ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
_lp_jolly_make_vcs+="${lp_terminal_format}${LP_MARK_WIFI}"
else
_lp_jolly_make_vcs+="${lp_terminal_format}${LP_MARK_WIFI}"
fi
else
_lp_jolly_make_vcs+="${lp_terminal_format}·"
fi
if _lp_http_proxy ; then
__jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_lp_jolly_make_vcs+="${jolly_sep}"
else
__jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_lp_jolly_make_vcs+="${jolly_sep}"
fi
if __jolly_prompt_vcs; then
_lp_jolly_make_vcs+="${_JOLLY_VCS}"
fi
}
_lp_jolly_make_input() {
####################################################################
# PROMPT LINE
####################################################################
_lp_jolly_make_input=
if _lp_runtime_format ; then
__jolly_make_sep_plug ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
__jolly_make_field "${lp_runtime_format}" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
_lp_jolly_make_input+="${jolly_sep}${jolly_field}"
fi
if _lp_error ; then
local error_msg=
if _lp_error_meaning; then
error_msg="${lp_error_meaning}"
else
error_msg="${lp_error}"
fi
__jolly_make_sep_link ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
__jolly_make_field "${JOLLY_MARK_ERROR}${JOLLY_SPACE_VOID}${error_msg}" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
_lp_jolly_make_input+="${jolly_sep}${jolly_field}"
fi
__jolly_make_sep_plug ${JOLLY_COLOR_MARK[@]+"${JOLLY_COLOR_MARK[@]}"}
_lp_jolly_make_input+="${jolly_sep}"
lp_terminal_format ${JOLLY_COLOR_MARK[@]+"${JOLLY_COLOR_MARK[@]}"}
local mark_color="$lp_terminal_format"
# No need to check LP_ENABLE_SHLVL, _lp_shell_level does it.
if _lp_shell_level ; then
local i
for ((i=0; i < lp_shell_level-1; i++)); do
_lp_jolly_make_input+="${mark_color}${JOLLY_MARK}"
done
fi
# Warning _lp_jolly_make_input mark if either root or sudo.
_lp_user
user="$?"
# No need to check LP_ENABLE_SUDO, _lp_sudo_active does it.
_lp_sudo_active
sudo="$?"
if [[ "$sudo" == 0 || "$user" == 2 ]] ; then
local dcwfg="${JOLLY_COLOR_WARN[_LP_FIRST_INDEX+1]}"
[[ -z $dcwfg ]] && dcwfg=-1
lp_terminal_format $dcwfg
_lp_jolly_make_input+="${lp_terminal_format}${JOLLY_MARK_SUDO}${JOLLY_MARK}"
else
_lp_jolly_make_input+="${mark_color}${JOLLY_MARK}"
fi
_lp_jolly_make_input+="${NO_COL}"
}
_lp_jolly_theme_prompt() {
local header side inline jolly_prompt
_lp_jolly_make_header
header+="$_lp_jolly_make_header"
_lp_jolly_make_side
side="$_lp_jolly_make_side"
# header/side assembling
if _lp_dirstack; then
lp_terminal_format ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
else
# Recall a dark format to correctly reset sections history
# to match the path's section colors.
lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
fi
__jolly_make_sep_last "$_lp_jolly_has_warns" "$_lp_jolly_has_notes"
header+="$jolly_sep"
# Right-align the $side with spaces.
_lp_fill "$header$NO_COL" "$side" " "
header="$lp_fill${NO_COL}"
_lp_jolly_make_env
local inline_left="$_lp_jolly_make_env_inline_left"
local inline_right="$_lp_jolly_make_env_inline_right"
_lp_jolly_inline_right+="${JOLLY_LINE}"
inline=
# FIXME deprecated
# # FIXME use _lp_fill-like function to handle multi-character line?
# if ((JOLLY_ENABLE_GRADIENT_LINE)); then
# # Fill up the center section with a line colored as a gradient.
# local ret
# __lp_strip_escapes "$_lp_jolly_make_env_inline_left"
# local left_as_text="$ret"
# local line_width=$((${COLUMNS:-80}-${#left_as_text}))
# local line="$_lp_jolly_make_env"
# local i c f a b j
# for ((i=0; i < line_width; i++)); do # For each character in the line.
# local dash_colors=()
# for ((c=_LP_FIRST_INDEX; c < 6+_LP_FIRST_INDEX; c++)); do # For each color parameter.
# a="${JOLLY_COLOR_LINE_START[c]}"
# b="${JOLLY_COLOR_LINE_END[c]}"
# j=$((a+(b-a)*i/line_width))
# dash_colors+=("$j")
# done
# lp_terminal_format "${dash_colors[@]}"
# line+="${lp_terminal_format}${JOLLY_LINE}"
# # line+="${lp_terminal_format}${i}(${dash_colors[@]}) "
# done
# _lp_jolly_make_env="${line}${NO_COL}"
# else
# Fill up the remaining space with a fixed-color line.
_lp_fill "$inline_left" "$inline_right" "$JOLLY_LINE"
# Format here is JOLLY_COLOR_LINE.
inline="${lp_terminal_format}${lp_fill}${NO_COL}"
# fi
_lp_jolly_make_vcs
jolly_prompt="$_lp_jolly_make_vcs"
_lp_jolly_make_input
jolly_prompt+="$_lp_jolly_make_input"
# Assemble and setup
local n=$'\n'
PS1="${n}${header}${n}${inline}${n}${jolly_prompt} "
}
########################################################################
# DotVector theme
########################################################################
_lp_dotvector_theme_activate() {
_lp_jolly_theme_activate
}
_lp_dotvector_theme_directory() {
_lp_jolly_theme_directory
}
_lp_dotvector_theme_prompt() {
local header side inline input vcs main
_lp_jolly_make_header
header+="$_lp_jolly_make_header"
_lp_jolly_make_side
side="$_lp_jolly_make_side"
# header/side assembling
if _lp_dirstack; then
lp_terminal_format ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
else
# Recall a dark format to correctly reset sections history
# to match the path's section colors.
lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
fi
__jolly_make_sep_last "$_lp_jolly_has_warns" "$_lp_jolly_has_notes"
header+="$jolly_sep"
_lp_jolly_make_vcs
lp_terminal_format -3 -1
local last_color="$lp_terminal_format"
lp_terminal_format ${JOLLY_COLOR_LINE[@]}
local line_color="$lp_terminal_format"
lp_terminal_format ${JOLLY_COLOR_LITE[_LP_FIRST_INDEX+0]} -1 0 0
local before="${line_color}${JOLLY_LINE}${lp_terminal_format}${JOLLY_LINK[_LP_FIRST_INDEX+2]}"
local after="${JOLLY_SPACE_VOID}${last_color}${JOLLY_LINK_R[_LP_FIRST_INDEX+0]}"
vcs="${before}${_lp_jolly_make_vcs}${after}"
# Right-align the $side with spaces.
# _lp_fill "$header$NO_COL" "$side" " "
# header="$lp_fill${NO_COL}"
_lp_jolly_make_env
local inline_left="$_lp_jolly_make_env_inline_left"
local inline_right="$_lp_jolly_make_env_inline_right"
_lp_jolly_inline_right+="${JOLLY_LINE}"
_lp_fill "${header}${vcs}${inline_left}" "${inline_right}${side}" "$JOLLY_LINE"
main="${lp_terminal_format}${lp_fill}${NO_COL}"
lp_terminal_format ${JOLLY_COLOR_LITE[@]}
local start="${lp_terminal_format}"
_lp_jolly_make_input
input="$start$_lp_jolly_make_input"
# Assemble and setup
local n=$'\n'
PS1="${n}${main}${n}${input} "
}
########################################################################
# Functions called at "activate" stage.
########################################################################
__jolly_activate_display() {
if _lp_connected_display ; then
__jolly_make_field "$JOLLY_DISPLAY_X11" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_JOLLY_DISPLAY="$jolly_field"
else
__jolly_make_field "$JOLLY_DISPLAY_TEXT" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_JOLLY_DISPLAY="$jolly_field"
fi
}
__jolly_activate_shell() {
((JOLLY_ENABLE_SHELL)) || return 2
if ((_LP_SHELL_zsh)) ; then
__jolly_make_sep_plug ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
__jolly_make_field "$JOLLY_SHELL_ZSH" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_JOLLY_SHELL="${jolly_sep}${jolly_field}"
else
__jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
__jolly_make_field "$JOLLY_SHELL_BASH" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_JOLLY_SHELL="${jolly_sep}${jolly_field}"
fi
}
__jolly_activate_connection() {
_lp_user
user_type="$?"
local user_color
case "$user_type" in
0) # logged-in user
user_color=(${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"})
;;
1) # other user
user_color=(${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"})
;;
2) # root
user_color=(${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"})
;;
esac
local connection
_lp_connection
case "$lp_connection" in
lcl)
__jolly_make_sep_plug "${user_color[@]}"
connection="${jolly_sep}"
;;
su)
__jolly_make_sep_link "${user_color[@]}"
connection="${jolly_sep}"
;;
ssh)
__jolly_make_sep_open "${user_color[@]}"
connection="${jolly_sep}"
;;
tel)
__jolly_make_sep_dang "${user_color[@]}"
connection="${jolly_sep}"
;;
*)
__jolly_make_sep_plug "${user_color[@]}"
connection="${jolly_sep}"
;;
esac
_JOLLY_CONNECTION="${connection}"
}
__jolly_activate_user() {
_lp_user
user_type="$?"
case "$user_type" in
0) # logged-in user
if [[ -z $lp_username ]] ; then # Honors LP_USER_ALWAYS
__jolly_make_field "$JOLLY_USER_LOCAL" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_JOLLY_USER="$jolly_field"
else
__jolly_make_field "$lp_username" ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
_JOLLY_USER="$jolly_field"
fi
;;
1) # other user
_lp_username_color
__jolly_make_field "$lp_username_color" ${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"}
_JOLLY_USER="$jolly_field"
;;
2) # root
_lp_username
__jolly_make_field "$lp_username" ${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"}
_JOLLY_USER="$jolly_field"
;;
esac
return $user_type
}
__jolly_activate_hostname() {
local hostname
if _lp_hostname; then
case "$lp_connection" in
ssh)
local client_ip client_port server_ip server_port hostname=
IFS=" " read -r client_ip client_port server_ip server_port <<<"$SSH_CONNECTION"
local username=${USER:-${USERNAME:-${LOGNAME-}}}
if _lp_create_link "ssh://${username}@${server_ip}:${server_port}" "$lp_hostname"; then
hostname="$link"
else
hostname="$lp_hostname"
fi
# If we want a different color for each host
if (( LP_ENABLE_SSH_COLORS )); then
LP_COLOR_SSH="$LP_COLOR_HOST_HASH"
hostname="${LP_COLOR_SSH}${hostname}"
else
hostname="${hostname}"
fi
;;
tel)
hostname="${lp_hostname}"
;;
*)
hostname+="${JOLLY_HOST_LOCAL}"
;;
esac
else
hostname="${JOLLY_HOST_LOCAL}"
fi
__jolly_make_field "$hostname" ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
_JOLLY_HOSTNAME="${jolly_field}"
}
__jolly_activate_multiplexer() {
local lp_multiplexer multiplexer
if _lp_multiplexer ; then
case "$lp_multiplexer" in
tmux)
__jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
multiplexer="${jolly_sep}"
;;
screen)
__jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
multiplexer="${jolly_sep}"
;;
*)
__jolly_make_sep_link ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
multiplexer="${jolly_sep}"
;;
esac
else
__jolly_make_sep_plug ${JOLLY_COLOR_LITE[@]+"${JOLLY_COLOR_LITE[@]}"}
multiplexer="${jolly_sep}"
fi
_JOLLY_MULTIPLEXER="${multiplexer}"
}
########################################################################
# Functions called at directory change.
########################################################################
__jolly_directory_FS() {
local fs=
if (( LP_ENABLE_PERM )); then
if _lp_chroot ; then
if [[ -w "$PWD" ]]; then
__jolly_make_sep_open ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
fs="$jolly_sep"
else
__jolly_make_sep_dang ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
fs="$jolly_sep"
fi
else
if [[ -w "$PWD" ]]; then
__jolly_make_sep_plug ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
fs="$jolly_sep"
else
__jolly_make_sep_link ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
fs="$jolly_sep"
fi
fi
fi
_JOLLY_FS="$fs"
}
__jolly_directory_path() {
local lp_terminal_format
lp_terminal_format ${JOLLY_COLOR_DARK[@]+"${JOLLY_COLOR_DARK[@]}"}
local path_format="${lp_terminal_format}"
lp_terminal_format ${JOLLY_COLOR_SEP_DARK[@]+"${JOLLY_COLOR_SEP_DARK[@]}"}
local separator_format=$lp_terminal_format
lp_terminal_format ${JOLLY_COLOR_PATH_SHORT[@]+"${JOLLY_COLOR_PATH_SHORT[@]}"}
local shortened_format=$lp_terminal_format
lp_terminal_format ${JOLLY_COLOR_PATH_VCS[@]+"${JOLLY_COLOR_PATH_VCS[@]}"}
local vcs_format=$lp_terminal_format
lp_terminal_format ${JOLLY_COLOR_PATH_LAST[@]+"${JOLLY_COLOR_PATH_LAST[@]}"}
local last_dir_format=$lp_terminal_format
local lp_path_format
_lp_path_format "$path_format" "$last_dir_format" "$vcs_format" "$shortened_format" \
"${JOLLY_SPACE_PATH}${JOLLY_SOFT}${JOLLY_SPACE_PATH}" "$separator_format"
_JOLLY_PATH=${lp_path_format}
}
########################################################################
# Functions called at jolly_prompt update.
########################################################################
__jolly_prompt_vcs() {
if _lp_find_vcs ; then
declare -a color color_behind color_ahead
_lp_smart_mark
_JOLLY_VCS=""
# Mark & commits off remote
if _lp_vcs_commits_off_remote; then # There is remote-space-[local].
_lp_vcs_remote # Get remote name.
if [[ "$lp_vcs_remote" == "origin" ]]; then
lp_vcs_remote="$JOLLY_VCS_REMOTE_ORIGIN"
fi
# Remote segment.
if [[ "$lp_vcs_commit_behind" -ne "0" ]]; then # NOTE remote segment.
if [[ "$lp_vcs_commit_behind" -ge "${JOLLY_VCS_BEHIND_THRESHOLD}" ]]; then
color_behind=(${JOLLY_COLOR_WARN[@]+"${JOLLY_COLOR_WARN[@]}"})
else
color_behind=(${JOLLY_COLOR_NOTE[@]+"${JOLLY_COLOR_NOTE[@]}"})
fi
if (( LP_ENABLE_VCS_DIFFSTATS )) ; then
__jolly_make_field "${lp_smart_mark}" "${color_behind[@]}"
_JOLLY_VCS+="$jolly_field"
__jolly_make_sep_soft ${JOLLY_COLOR_SEP_LITE[@]+"${JOLLY_COLOR_SEP_LITE[@]}"}