-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolid.theme
1440 lines (1237 loc) · 46.3 KB
/
solid.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
_lp_solid_theme_activate() {
if ! _lp_version_greatereq 2 2 0 ; then
_lp_join "." ${_LP_VERSION[@]}
printf "WARNING: the Solid 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
local lp_terminal_format
lp_terminal_format 63 -1 0 0 4 0
SP_COLOR_BASE="$lp_terminal_format"
lp_terminal_format 30 -1 0 0 6 0
SP_COLOR_NOTE="$lp_terminal_format"
lp_terminal_format 214 -1 0 0 11 0
SP_COLOR_WARN="$lp_terminal_format"
SP_MARK_HIDDEN="/" #·▨■✗✘✕✖X/░╱╳
LP_COLOR_PATH="$SP_COLOR_NOTE"
LP_COLOR_PATH_LAST_DIR="$SP_COLOR_WARN"
LP_COLOR_PATH_VCS_ROOT="$SP_COLOR_WARN"
LP_COLOR_PATH_SHORTENED="$SP_COLOR_BASE"
LP_COLOR_PATH_SEPARATOR="$SP_COLOR_BASE"
#0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85
#|····|····|····|····|····|····|····|····|····|····|····|····|····|····|····|····|····|
#readonly
BOARD_TEMPLATE=(
'┌────────────────┐┌──────────────────────────────────┐ SOLID PROMPT ┌─────┐' # 0
'│2.2.0 vs [ ]││ VCS:[ ] remt:[ ]├──────────────────╥┘ OS:◌└────┄·' # 1
'├────────────────┴┤ diff:[ ] hdst:[ ]║pyev:[ ]║krnl:' # 2
'│ ⎧load:[ ]║comit:[ ] bkmk:[ ]║node:[ ]║fmly:' # 3
'│ ⎪ ram:[ ]║stash:[ ] vers:[ ]║ruby:[ ]║dstr:' # 4
'│snsr⎨batt:[ ]║utrak:[ ] brch:[ ]║kube:[ ]║vers:' # 5
'│ ⎪disk:[ ]╠══════════════════════════════════╣trfm:[ ]║arch:' # 6
'│ ⎩temp:[ ]║X11:◌ su:◌ sudo:◌ proxy:◌ chroot:◌║cont:[ ]╚═══════════┄·' # 7
'╞═════════════════╬═══════════╦══════════════════════╣awsp:[ ] modl:' # 8
'│ ⎧suspd:[ ]║shlvl:[ ]║ptag:[ ]║scls:[ ] envv:' # 9
'│jobs⎨bkgrd:[ ]║ RSH:◌ ║user:[ ]║shel:[ ]╔═════╗ cmak:' # 10
'│ ⎩dtchd:[ ]║ mux:◌ ║host:[ ]╠═══════════╝ RO:◌╚╦═══════════┄·' # 11
'╞═════════════════╩═══════════╩══════════════════════╝rntm:[ ]║erro:[ ]' # 12
'│drstk:[ ] path:[ ]║emng:' # 13
'├───────────────────────────────────────────────────────────────────────╨───────────┄·' # 14
#|····|····|····|····|····|····|····|····|····|····|····|····|····|····|····|····|····|
#0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85
)
declare -A -g BOARD_LOC
BOARD_LOC["lp_version"]="1 11 5"
BOARD_LOC["load"]="3 12 5"
BOARD_LOC["mram"]="4 12 5"
BOARD_LOC["batt"]="5 12 5"
BOARD_LOC["disk"]="6 12 5"
BOARD_LOC["temp"]="7 12 5"
BOARD_LOC["suspd"]="9 13 4"
BOARD_LOC["bkgrd"]="10 13 4"
BOARD_LOC["dtchd"]="11 13 4"
BOARD_LOC["shlvl"]="9 26 3"
BOARD_LOC["RSH"]="10 25 1"
BOARD_LOC["mux"]="11 25 1"
BOARD_LOC["X11"]="7 23 1"
BOARD_LOC["su"]="7 28 1"
BOARD_LOC["sudo"]="7 35 1"
BOARD_LOC["proxy"]="7 43 1"
BOARD_LOC["chroot"]="7 52 1"
BOARD_LOC["VCS"]="1 26 7"
BOARD_LOC["diff"]="2 26 7"
BOARD_LOC["comit"]="3 26 7"
BOARD_LOC["stash"]="4 26 7"
BOARD_LOC["utrak"]="5 26 7"
BOARD_LOC["remt"]="1 41 11"
BOARD_LOC["hdst"]="2 41 11"
BOARD_LOC["bkmk"]="3 41 11"
BOARD_LOC["vers"]="4 41 11"
BOARD_LOC["brch"]="5 41 11"
BOARD_LOC["ptag"]="9 37 15"
BOARD_LOC["user"]="10 37 15"
BOARD_LOC["host"]="11 37 15"
BOARD_LOC["rntm"]="12 60 11"
BOARD_LOC["RO"]="11 70 1"
BOARD_LOC["drstk"]="13 8 3"
LP_PATH_LENGTH=51
BOARD_LOC["path"]="13 19 $LP_PATH_LENGTH"
BOARD_LOC["pyev"]="2 60 11"
BOARD_LOC["node"]="3 60 11"
BOARD_LOC["ruby"]="4 60 11"
BOARD_LOC["kube"]="5 60 11"
BOARD_LOC["trfm"]="6 60 11"
BOARD_LOC["cont"]="7 60 11"
BOARD_LOC["awsp"]="8 60 11"
BOARD_LOC["scls"]="9 60 11"
BOARD_LOC["shel"]="10 60 4"
BOARD_LOC["os"]="1 78 1"
BOARD_LOC["krnl"]="2 78 0"
BOARD_LOC["fmly"]="3 78 0"
BOARD_LOC["dstr"]="4 78 0"
BOARD_LOC["osvers"]="5 78 0"
BOARD_LOC["arch"]="6 78 0"
BOARD_LOC["modl"]="8 78 0"
BOARD_LOC["envv"]="9 78 0"
BOARD_LOC["cmak"]="10 78 0"
BOARD_LOC["error"]="12 79 3"
BOARD_LOC["emng"]="13 79 0"
_lp_default_theme_activate
}
_lp_solid_theme_directory() {
_lp_default_theme_directory
}
__lp_board_put() { # what field [color [shorten_char="…"]]
# WARNING: this should be called on fields ordered from left to right in the board order.
local what="$1"
[[ -n "$what" ]] || return 1
local field="$2"
[[ -n "$field" ]] || return 1
local color="${3-}"
local shorten_char=${4-"…"}
# printf "\n##### ${field} #####\n"
# __lp_escape "$what"
# local ewhat="$ret"
# # printf "ewhat:«%s${NO_COL}»\n" "$ewhat"
# # printf "ewhat:«%q»\n" "$ewhat"
# raw_col raw_after
# │ │
#| inprefix:[1] | field:[raw_data ] |
#└──────────┬───────────┘└──┬───┘
# raw_prefix_len raw_data_len
# └─────┬─────┘
# raw_field_len
# └───┬──┘
# raw_suffix_len
#└──────────────────┬───────────────────┘
# raw_total_len
#
# delta col after
# ┌─┬──┬─┐ │ │
#| inprefix:[\[\]1\[\]] | field:[\[\]raw_data\[\] ] |
#└───────────────┬──────────────┘└──────┬───────┘
# prefix_len data_len
# Read field's parameters.
local row raw_col raw_field_len
IFS=" " read -r row raw_col raw_field_len <<<"${BOARD_LOC["$field"]}"
if (( _LP_SHELL_zsh )); then
# FIXME use _LP_FIRST_INDEX to avoid a test.
# 1-indexing
row=$((row+1))
raw_col=$((raw_col+1))
fi
# Remove any invisible characters (colors),
# to get a visible length.
__lp_strip_escapes "$what"
local raw_data="$ret"
# printf "ZERO raw_data:«%s»\n" "${raw_data}"
# printf "ZERO raw_data:«%q»\n" "${raw_data}"
local raw_data_len=${#raw_data}
# __lp_escape "$what"
# local data="$ret"
local data="$what"
local data_len=${#data}
if (( _LP_SHELL_zsh )); then
local board_value="${BOARD_TEMPLATE[row][raw_col,raw_col+raw_field_len]}"
else
local board_value="${BOARD_TEMPLATE[row]:raw_col:raw_field_len}"
fi
# Replace any single character with the boolean mark.
if [[ "$raw_data" == "$SP_MARK_HIDDEN" ]]; then
local i
data="$SP_MARK_HIDDEN"
if [[ $raw_field_len -eq 0 ]]; then
data="$SP_MARK_HIDDEN"
else
for (( i=1; i < raw_field_len; i++ )) ; do
data+="$SP_MARK_HIDDEN"
done
fi
data_len=$raw_field_len
raw_data="$data"
raw_data_len=$data_len
elif [[ $raw_field_len -eq 1 && "$raw_data" != "0" ]]; then
if [[ "$board_value" == "◌" ]]; then
data="●"
elif [[ "$board_value" == " " ]]; then
if (( _LP_SHELL_zsh )); then
data="${raw_data[1,2]}"
else
data="${raw_data:0:1}"
fi
else
data="$board_value"
fi
data_len=1
raw_data="$data"
raw_data_len=1
fi
# printf "FIRST raw_data:«${raw_data}»\n"
# printf "$raw_field_len -ne 0 && $raw_data_len -gt $raw_field_len\n"
# If the data is too large to fit the field.
if [[ $raw_field_len -ne 0 && $raw_data_len -gt $raw_field_len ]]; then # FIXME shorten too much by one char.
if (( _LP_SHELL_zsh )); then
#Here, raw_field_len == 1+raw_field_len-1
raw_data="${raw_data[1,1+raw_field_len-${#shorten_char}]}${shorten_char}"
else
# Shorten to fit the field.
raw_data="${raw_data:0:$((raw_field_len-${#shorten_char}))}${shorten_char}"
fi
raw_data_len="$raw_field_len"
data="$raw_data" # FIXME this remove any color.
data_len="$raw_data_len"
fi
# printf "SECOND raw_data:«${raw_data}»\n"
local raw_total_len=${#BOARD_TEMPLATE[$row]}
local delta=${BOARD_DELTA[$row]}
# local col=$((raw_col+delta))
local raw_prefix_len=$raw_col
local prefix_len=$((raw_prefix_len+delta))
local raw_after=$((raw_prefix_len+raw_data_len))
# local after=$((prefix_len+data_len))
local raw_suffix_len=$((raw_total_len-raw_after))
if (( _LP_SHELL_zsh )); then
local prefix="${BOARD_CURRENT[$row][1,prefix_len-1]}"
local suffix="${BOARD_TEMPLATE[$row][raw_after,raw_after+raw_suffix_len]}"
else
local prefix="${BOARD_CURRENT[$row]:0:prefix_len}"
local suffix="${BOARD_TEMPLATE[$row]:raw_after:raw_suffix_len}"
fi
# printf "what:«${what}»\nraw_data:«${raw_data}»\n"
# printf "prefix:«${prefix}\ncolor:«${color}color»\ndata:«${data}»\nsuffix:«${suffix}»\n"
local line="${prefix}${color}${data}${SP_COLOR_BASE}${suffix}"
BOARD_CURRENT[$row]="$line"
local color_shift=$((data_len-raw_data_len+${#color}+${#SP_COLOR_BASE}))
BOARD_DELTA[$row]=$((delta+color_shift))
}
# __sp_strip_escapes() {
# if ! shopt -q extglob ; then
# local _lp_no_extglob=true
# shopt -s extglob
# fi
# ret="${1//"${_LP_OPEN_ESC}"!(*"${_LP_CLOSE_ESC}"*)"${_LP_CLOSE_ESC}"}"
# if [[ -n ${_lp_no_extglob-} ]]; then
# shopt -u extglob
# fi
# ret="${ret//\\\\/\\}"
# if shopt -q promptvars ; then
# ret="${ret//\\\$/\$}"
# ret="${ret//\\\`/\`}"
# fi
# }
_lp_solid_theme_prompt() {
local color
_lp_default_theme_prompt_data
# Copy a fresh template.
BOARD_CURRENT=("${BOARD_TEMPLATE[@]}")
BOARD_DELTA=(
0 # 0
0 # 1
0 # 2
0 # 3
0 # 4
0 # 5
0 # 6
0 # 7
0 # 8
0 # 9
0 # 10
0 # 11
0 # 12
0 # 13
)
# Prompt line # 0 : no data
# Prompt line #1
if [[ "${#_LP_VERSION[@]}" -gt 0 ]]; then
local lp_version="${_LP_VERSION[_LP_FIRST_INDEX+0]}.${_LP_VERSION[_LP_FIRST_INDEX+1]}.${_LP_VERSION[_LP_FIRST_INDEX+2]}"
if _lp_version_greatereq 2 2 0; then
__lp_board_put "$lp_version" "lp_version" "$SP_COLOR_NOTE"
else
__lp_board_put "$lp_version" "lp_version" "$SP_COLOR_WARN"
fi
else
__lp_board_put "?.?.?" "lp_version" "$SP_COLOR_BASE"
fi
if ! _lp_are_vcs_enabled; then
__lp_board_put "$SP_MARK_HIDDEN" "VCS" "$SP_COLOR_BASE"
else
_lp_find_vcs
local found_vcs="$?"
if [[ $found_vcs -eq 0 ]]; then
__lp_board_put "$lp_vcs_type" "VCS" "$SP_COLOR_NOTE"
if _lp_vcs_remote; then
__lp_board_put "$lp_vcs_remote" "remt" "$SP_COLOR_NOTE"
fi
fi
fi
if (( LP_ENABLE_OS )); then
__lp_board_put "1" "os" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "os" "$SP_COLOR_BASE"
fi
# Prompt line #2
if _lp_are_vcs_enabled; then
_lp_find_vcs
local found_vcs="$?"
if [[ $found_vcs -eq 0 ]]; then
if _lp_vcs_uncommitted_files; then
local ret has_lines=
_lp_vcs_unstaged_lines; ret=$?
# Only show unstaged changes if the VCS supports staging, otherwise
# show uncommitted changes
if (( ret == 0 )); then
has_lines="+$lp_vcs_unstaged_i_lines/-$lp_vcs_unstaged_d_lines"
elif (( ret == 1 )); then
has_lines="+0/-0"
else
_lp_vcs_uncommitted_lines
has_lines="+$lp_vcs_uncommitted_i_lines/-$lp_vcs_uncommitted_d_lines"
fi
__lp_board_put "$has_lines" "diff" "$SP_COLOR_NOTE"
fi
if _lp_vcs_head_status; then
__lp_board_put "$lp_vcs_head_status" "hdst" "$SP_COLOR_NOTE"
# TODO lp_vcs_head_details
fi
fi
fi
if (( LP_ENABLE_VIRTUALENV )); then
if _lp_python_env; then
__lp_board_put "$lp_python_env" "pyev" "$SP_COLOR_NOTE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "pyev" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_OS )); then
_lp_os # No need to call it later again.
if (( LP_ENABLE_OS_KERNEL )); then
__lp_board_put "$lp_os_kernel" "krnl" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "krnl" "$SP_COLOR_BASE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "krnl" "$SP_COLOR_BASE"
fi
# Prompt line #3
if (( LP_ENABLE_LOAD )); then
if _lp_load; then
color="$SP_COLOR_WARN"
else
color="$SP_COLOR_NOTE"
fi
__lp_board_put "${lp_load_adjusted}" "load" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "load" "$SP_COLOR_BASE"
fi
if ! _lp_are_vcs_enabled; then
__lp_board_put "$SP_MARK_HIDDEN" "bkmk" "$SP_COLOR_BASE"
else
if [[ $found_vcs -eq 0 ]]; then
if _lp_vcs_commits_off_remote; then
local has_commit=
if [[ "$lp_vcs_commit_ahead" -ne "0" && "$lp_vcs_commit_behind" -ne "0" ]]; then
# has_commit="${LP_COLOR_COMMITS}+$lp_vcs_commit_ahead${NO_COL}/${LP_COLOR_COMMITS_BEHIND}-$lp_vcs_commit_behind${NO_COL}"
has_commit="+$lp_vcs_commit_ahead/-$lp_vcs_commit_behind"
elif [[ "$lp_vcs_commit_ahead" -ne "0" ]]; then
# has_commit="${LP_COLOR_COMMITS}$lp_vcs_commit_ahead${NO_COL}"
has_commit="$lp_vcs_commit_ahead"
elif [[ "$lp_vcs_commit_behind" -ne "0" ]]; then
# has_commit="${LP_COLOR_COMMITS_BEHIND}-$lp_vcs_commit_behind${NO_COL}"
has_commit="-$lp_vcs_commit_behind"
fi
__lp_board_put "$has_commit" "comit" "$SP_COLOR_NOTE"
fi
if _lp_vcs_bookmark; then
__lp_board_put "$lp_vcs_bookmark" "bkmk" "$SP_COLOR_NOTE"
fi
fi
fi
if (( LP_ENABLE_NODE_VENV )); then
__lp_board_put "$LP_NODE_VENV" "node" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "node" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_OS )); then
if (( LP_ENABLE_OS_FAMILY )); then
__lp_board_put "$lp_os_family" "fmly" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "fmly" "$SP_COLOR_BASE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "fmly" "$SP_COLOR_BASE"
fi
# Prompt line #4
if (( LP_ENABLE_RAM )); then
if _lp_ram; then
color="$SP_COLOR_WARN"
else
color="$SP_COLOR_NOTE"
fi
__lp_board_put "${lp_ram_perc}${_LP_PERCENT}" "mram" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "mram" "$SP_COLOR_BASE"
fi
if ! _lp_are_vcs_enabled; then
__lp_board_put "$SP_MARK_HIDDEN" "vers" "$SP_COLOR_BASE"
else
if [[ $found_vcs -eq 0 ]]; then
if _lp_vcs_stash_count; then
__lp_board_put "$lp_vcs_stash_count" "stash" "$SP_COLOR_NOTE"
fi
if ! _lp_vcs_branch; then
if _lp_vcs_tag; then
__lp_board_put "$lp_vcs_tag" "vers" "$SP_COLOR_NOTE"
else
_lp_vcs_commit_id
__lp_board_put "$lp_vcs_commit_id" "vers" "$SP_COLOR_NOTE"
fi
fi
fi
fi
if (( LP_ENABLE_RUBY_VENV )); then
__lp_board_put "$LP_RUBY_VENV" "ruby" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "ruby" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_OS )); then
if (( LP_ENABLE_OS_DISTRIB )); then
__lp_board_put "$lp_os_distrib" "dstr" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "dstr" "$SP_COLOR_BASE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "dstr" "$SP_COLOR_BASE"
fi
# Prompt line #5
if (( LP_ENABLE_BATT )); then
_lp_battery
local -i _status="$?"
local sp_batt
if (( _status >= 4 )); then
# no battery support or battery full
if (( lp_battery == 100 )); then
# battery full
sp_batt="${lp_battery}"
color="$SP_COLOR_NOTE"
fi
elif (( _status == 3 )); then
# charging and above threshold and not 100%
sp_batt="↑${lp_battery}"
color="$SP_COLOR_NOTE"
elif (( _status == 2 )); then
# charging but under threshold
sp_batt="↑${lp_battery}"
color="$SP_COLOR_WARN"
elif (( _status == 1 )); then
# discharging but above threshold
sp_batt="↓${lp_battery}"
color="$SP_COLOR_NOTE"
else
# discharging and under threshold
sp_batt="↓${lp_battery}"
color="$SP_COLOR_WARN"
fi
__lp_board_put "${sp_batt}${_LP_PERCENT}" "batt" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "batt" "$SP_COLOR_BASE"
fi
if ! _lp_are_vcs_enabled; then
__lp_board_put "$SP_MARK_HIDDEN" "brch" "$SP_COLOR_BASE"
else
if [[ $found_vcs -eq 0 ]]; then
if _lp_vcs_untracked_files; then
__lp_board_put "$lp_vcs_untracked_files" "utrak" "$SP_COLOR_NOTE"
fi
if _lp_vcs_branch; then
__lp_board_put "$lp_vcs_branch" "brch" "$SP_COLOR_NOTE"
fi
fi
fi
if (( LP_ENABLE_KUBECONTEXT )); then
__lp_board_put "$LP_KUBECONTEXT" "kube" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "kube" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_OS )); then
if (( LP_ENABLE_OS_VERSION )); then
__lp_board_put "$lp_os_vers" "osvers" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "osvers" "$SP_COLOR_BASE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "osvers" "$SP_COLOR_BASE"
fi
# Prompt line #6
if (( LP_ENABLE_DISK )); then
if _lp_disk; then
color="$SP_COLOR_WARN"
else
color="$SP_COLOR_NOTE"
fi
__lp_board_put "${lp_disk_perc}${_LP_PERCENT}" "disk" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "disk" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_TERRAFORM )); then
__lp_board_put "$LP_TFSPACE" "trfm" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "trfm" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_OS )); then
if (( LP_ENABLE_OS_ARCH )); then
__lp_board_put "$lp_os_arch" "arch" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "arch" "$SP_COLOR_BASE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "arch" "$SP_COLOR_BASE"
fi
# Prompt line #7
if (( LP_ENABLE_TEMP )); then
if _lp_temperature; then
color="$SP_COLOR_WARN"
else
color="$SP_COLOR_NOTE"
fi
__lp_board_put "$lp_temperature°" "temp" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "temp" "$SP_COLOR_BASE"
fi
# TODO add LP_ENABLE_DISPLAY in Liquid Prompt
if _lp_connected_display; then
__lp_board_put "1" "X11" "$SP_COLOR_NOTE"
fi
if _lp_hostname; then
if [[ "$lp_connection" == "su" ]]; then
__lp_board_put "1" "su" "$SP_COLOR_WARN"
fi
fi
if (( LP_ENABLE_SUDO )); then
if _lp_sudo_active; then
__lp_board_put "1" "sudo" "$SP_COLOR_WARN"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "sudo" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_PROXY )); then
__lp_board_put "$LP_PROXY" "proxy" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "proxy" "$SP_COLOR_BASE"
fi
# TODO add LP_ENABLE_CHROOT in Liquid Prompt
if _lp_chroot; then
__lp_board_put "1" "chroot" "$SP_COLOR_WARN"
fi
if (( LP_ENABLE_CONTAINER )); then
__lp_board_put "$LP_CONTAINER" "cont" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "cont" "$SP_COLOR_BASE"
fi
# Prompt line #8
if (( LP_ENABLE_AWS_PROFILE )); then
__lp_board_put "$LP_AWS_PROFILE" "awsp" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "awsp" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_MODULES )); then
__lp_board_put "$LP_MODULES" "modl" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "modl" "$SP_COLOR_BASE"
fi
# Prompt line #9
if (( LP_ENABLE_JOBS )); then
_lp_jobcount
if [[ $lp_stopped_jobs -gt 0 ]]; then
color="$SP_COLOR_NOTE"
else
color="$SP_COLOR_BASE"
fi
__lp_board_put "$lp_stopped_jobs" "suspd" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "suspd" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_SHLVL )); then
if _lp_shell_level; then
color="$SP_COLOR_NOTE"
else
color="$SP_COLOR_BASE"
fi
__lp_board_put "$lp_shell_level" "shlvl" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "shlvl" "$SP_COLOR_BASE"
fi
__lp_board_put "$LP_PS1_PREFIX" "ptag" "$SP_COLOR_NOTE"
if (( LP_ENABLE_SCLS )); then
__lp_board_put "$LP_SCLS" "scls" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "scls" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_ENV_VARS )); then
if _lp_env_vars; then
_lp_join "${SP_COLOR_BASE}][${SP_COLOR_NOTE}" ${lp_env_vars[@]}
__lp_board_put "${SP_COLOR_BASE}[${SP_COLOR_NOTE}$lp_join${SP_COLOR_BASE}]${NO_COL}" "envv" "${SP_COLOR_NOTE}"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "envv" "$SP_COLOR_BASE"
fi
# Prompt line #10
if (( LP_ENABLE_JOBS )); then
if [[ $lp_running_jobs -gt 0 ]]; then
color="$SP_COLOR_NOTE"
else
color="$SP_COLOR_BASE"
fi
__lp_board_put "$lp_running_jobs" "bkgrd" "$color"
fi
if _lp_hostname; then # FIXME alredy called for line 9.
case "$lp_connection" in
ssh)
__lp_board_put "1" "RSH" "$SP_COLOR_NOTE"
;;
#su) # TODO
# ;;
tel)
__lp_board_put "1" "RSH" "$SP_COLOR_WARN"
;;
esac
fi
if _lp_username; then
_lp_user
if [[ $? -eq 2 ]]; then # Root
color="$SP_COLOR_WARN"
else
color="$SP_COLOR_NOTE"
fi
__lp_board_put "$lp_username" "user" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "user" "$SP_COLOR_BASE"
fi
if ((_LP_SHELL_zsh)); then
__lp_board_put "zsh" "shel" "$SP_COLOR_NOTE"
else
__lp_board_put "bash" "shel" "$SP_COLOR_NOTE"
fi
if (( LP_ENABLE_CMAKE )); then
if _lp_cmake; then
local cm=
[[ -n "${lp_cmake_c_compiler}" ]] && cm+="[${SP_COLOR_NOTE}${lp_cmake_c_compiler}${SP_COLOR_BASE}]"
[[ -n "${lp_cmake_cxx_compiler}" ]] && cm+="[${SP_COLOR_NOTE}${lp_cmake_cxx_compiler}${SP_COLOR_BASE}]"
[[ -n "${lp_cmake_generator}" ]] && cm+="[${SP_COLOR_NOTE}${lp_cmake_generator}${SP_COLOR_BASE}]"
[[ -n "${lp_cmake_buildtype}" ]] && cm+="[${SP_COLOR_NOTE}${lp_cmake_buildtype}${SP_COLOR_BASE}]"
__lp_board_put "$cm" "cmak"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "cmak" "$SP_COLOR_BASE"
fi
# Prompt line #11
if (( LP_ENABLE_DETACHED_SESSIONS )); then
_lp_detached_sessions
if [[ $lp_detached_sessions -gt 0 ]]; then
color="$SP_COLOR_NOTE"
else
color="$SP_COLOR_BASE"
fi
__lp_board_put "$lp_detached_sessions" "dtchd" "$color"
else
__lp_board_put "$SP_MARK_HIDDEN" "dtchd" "$SP_COLOR_BASE"
fi
# TODO: add LP_ENABLE_TMUX todo Liquid Prompt
if _lp_multiplexer; then
__lp_board_put "$lp_multiplexer" "mux" "$SP_COLOR_NOTE"
fi
if _lp_hostname; then # FIXME alredy called for line 9.
__lp_board_put "$lp_hostname" "host" "$SP_COLOR_NOTE"
else
__lp_board_put "$SP_MARK_HIDDEN" "host" "$SP_COLOR_BASE"
fi
if [[ ! -w "${PWD}" ]]; then
__lp_board_put "1" "RO" "$SP_COLOR_WARN"
fi
# Prompt line #12
if (( LP_ENABLE_RUNTIME )); then
if _lp_runtime_format; then
local color="$SP_COLOR_NOTE"
if (( _LP_RUNTIME_SECONDS >= LP_RUNTIME_THRESHOLD )); then
color="$SP_COLOR_WARN"
fi
__lp_board_put "$lp_runtime_format" "rntm" "$color"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "rntm" "$SP_COLOR_BASE"
fi
if (( LP_ENABLE_ERROR )); then
if _lp_error; then
__lp_board_put "$lp_error" "error" "$SP_COLOR_NOTE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "error" "$SP_COLOR_BASE"
fi
# Prompt line #13 : no data
if (( LP_ENABLE_DIRSTACK )); then
if _lp_dirstack; then
__lp_board_put "$lp_dirstack" "drstk" "$SP_COLOR_NOTE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "drstk" "$SP_COLOR_BASE"
fi
# local lp_path_format
# _lp_path_format "$LP_COLOR_PATH" "$LP_COLOR_PATH_LAST_DIR" "$LP_COLOR_PATH_VCS_ROOT" "$LP_COLOR_PATH_SHORTENED" "/" "$LP_COLOR_PATH_SEPARATOR"
# __sp_strip_escapes "$lp_path_format"
# __lp_board_put "<$ret>" "path" # No forced color, already set as global config.
# __lp_board_put "<$lp_path_format>" "path" # No forced color, already set as global config.
__lp_board_put "$LP_PWD" "path" # No forced color, already set as global config.
if (( LP_ENABLE_ERROR )); then
if (( LP_ENABLE_ERROR_MEANING )); then
if _lp_error; then
__lp_board_put "${SP_COLOR_BASE}[${SP_COLOR_NOTE}$lp_error_meaning${SP_COLOR_BASE}]" "emng" "$SP_COLOR_NOTE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "emng" "$SP_COLOR_BASE"
fi
else
__lp_board_put "$SP_MARK_HIDDEN" "emng" "$SP_COLOR_BASE"
fi
local n=$'\n'
PS1="$n"
for line in "${BOARD_CURRENT[@]}"; do
PS1+="${SP_COLOR_BASE}${line}${n}"
done
PS1+="└ ${NO_COL}"
}
_lp_smallid_theme_activate() {
if ! _lp_version_greatereq 2 2 0 ; then
_lp_join "." ${_LP_VERSION[@]}
printf "WARNING: the Smallid 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
local lp_terminal_format
lp_terminal_format 243 -1 0 0 4 0
SP_COLOR_BASE="$lp_terminal_format"
lp_terminal_format 11 -1 0 0 6 0
SP_COLOR_NOTE="$lp_terminal_format"
lp_terminal_format 9 -1 0 0 11 0
SP_COLOR_WARN="$lp_terminal_format"
SP_MARK_HIDDEN="░" #─/·▨■✗✘✕✖X/░╱╳
LP_COLOR_PATH="$SP_COLOR_NOTE"
LP_COLOR_PATH_LAST_DIR="$SP_COLOR_WARN"
LP_COLOR_PATH_VCS_ROOT="$SP_COLOR_WARN"
LP_COLOR_PATH_SHORTENED="$SP_COLOR_BASE"
LP_COLOR_PATH_SEPARATOR="$SP_COLOR_BASE"
#Double-width char
#⬇
#0 5 10 15 20 25 30 35 40 45 50 55
#|X····|····|····|····|····|····|····|····|····|····|····|·
#0 5 10 15 20 25 30 35 40 45 50 55
#|X····|····|····|····|···X·|····|····|····|····|····|····|·
#0 5 10 15 20 25 30 35 40 45 50 55
#|X····|····|····|····|···X·|····|····|····|X····|····|····|·
#readonly
BOARD_TEMPLATE=(
'🤖[______]─[______]─[ ]·🧿─[___]─[___]─[___]─[___]─[___]' # 0 user host shell OS...
'🌳[y]─[n]─[r]─[k]─[t]─[o]─[a]─[s]─[m]─[c]─[____________]' # 1 envs
'⏱️ [L]─[M]─[ ]─[D]─[T]··📚─[z]─[k]─[d]┐··🔐─[û]─[ů]─[ç] ' # 2 sensors jobs rights
'⚠️ [E]─[_______]─[___]··🔗─[↥]─[X]─[m]┴[s]··🏷️ ─[____]├[d]' # 3 err mean rntm rmot tag drstck
'📍[____________________________________________]─[⛨]┴[S]' # 4 path RO shlvl
'🔖[ ]─[____]─[c]··[C]─[_____]─[v]─[b]─[____]─[d]─[s]─[u]' # 5 VCS
#|X····|····|····|····|····|····|····|····|····|····|····|·
#0 5 10 15 20 25 30 35 40 45 50 55
)
declare -A -g BOARD_LOC
# BOARD_LOC["lp_version"]="0 11 5"
BOARD_LOC["user"]="0 2 6"
BOARD_LOC["host"]="0 11 6"
BOARD_LOC["shel"]="0 20 1"
BOARD_LOC["arch"]="0 26 3"
BOARD_LOC["krnl"]="0 32 3"
BOARD_LOC["fmly"]="0 38 3"
BOARD_LOC["dstr"]="0 44 3"
BOARD_LOC["osvers"]="0 50 3"
BOARD_LOC["pyev"]="1 2 1"
BOARD_LOC["node"]="1 6 1"
BOARD_LOC["ruby"]="1 10 1"
BOARD_LOC["kube"]="1 14 1"
BOARD_LOC["trfm"]="1 18 1"
BOARD_LOC["cont"]="1 22 1"
BOARD_LOC["awsp"]="1 26 1"
BOARD_LOC["scls"]="1 30 1"
BOARD_LOC["modl"]="1 34 1"
BOARD_LOC["cmak"]="1 38 1"
BOARD_LOC["envv"]="1 42 12"
BOARD_LOC["load"]="2 4 1"
BOARD_LOC["mram"]="2 8 1"
BOARD_LOC["batt"]="2 12 1"
BOARD_LOC["disk"]="2 16 1"
BOARD_LOC["temp"]="2 20 1"
BOARD_LOC["suspd"]="2 27 1"
BOARD_LOC["bkgrd"]="2 31 1"
BOARD_LOC["dtchd"]="2 35 1"
BOARD_LOC["su"]="2 43 1"
BOARD_LOC["sudo"]="2 47 1"
BOARD_LOC["chroot"]="2 51 1"
BOARD_LOC["error"]="3 4 1"
BOARD_LOC["emng"]="3 8 7"
BOARD_LOC["rntm"]="3 18 3"
BOARD_LOC["proxy"]="3 27 1"
BOARD_LOC["X11"]="3 31 1"
BOARD_LOC["mux"]="3 35 1"
BOARD_LOC["RSH"]="3 39 1"
BOARD_LOC["ptag"]="3 48 4"
BOARD_LOC["drstk"]="3 55 1"
LP_PATH_LENGTH=44
BOARD_LOC["path"]="4 2 $LP_PATH_LENGTH"
BOARD_LOC["RO"]="4 49 1"
BOARD_LOC["shlvl"]="4 53 1"
BOARD_LOC["VCS"]="5 2 1"
BOARD_LOC["remt"]="5 6 4"
BOARD_LOC["behind"]="5 13 1"
BOARD_LOC["ahead"]="5 18 1"
BOARD_LOC["brch"]="5 22 5"
BOARD_LOC["vers"]="5 30 1"
BOARD_LOC["bkmk"]="5 34 1"
BOARD_LOC["hdst"]="5 38 4"
BOARD_LOC["diff"]="5 45 1"
BOARD_LOC["stash"]="5 49 1"
BOARD_LOC["utrak"]="5 53 1"
_lp_default_theme_activate
}
_lp_smallid_theme_directory() {
_lp_default_theme_directory
}
_lp_smallid_theme_prompt() {
local color
_lp_default_theme_prompt_data
# Copy a fresh template.
BOARD_CURRENT=("${BOARD_TEMPLATE[@]}")
BOARD_DELTA=(
0 # 0
0 # 1
0 # 2
0 # 3
0 # 4
0 # 5
0 # 6
0 # 7
0 # 8
0 # 9
0 # 10
0 # 11
0 # 12
0 # 13
)
# if [[ "${#_LP_VERSION[@]}" -gt 0 ]]; then
# local lp_version="${_LP_VERSION[_LP_FIRST_INDEX+0]}.${_LP_VERSION[_LP_FIRST_INDEX+1]}.${_LP_VERSION[_LP_FIRST_INDEX+2]}"
# if _lp_version_greatereq 2 2 0; then
# __lp_board_put "$lp_version" "lp_version" "$SP_COLOR_NOTE"
# else
# __lp_board_put "$lp_version" "lp_version" "$SP_COLOR_WARN"
# fi
# else
# __lp_board_put "?.?.?" "lp_version" "$SP_COLOR_BASE"
# fi
# Prompt line #0
if _lp_username; then
_lp_user
if [[ $? -eq 2 ]]; then # Root
color="$SP_COLOR_WARN"
else
color="$SP_COLOR_NOTE"
fi