-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtartify
More file actions
executable file
·3309 lines (2820 loc) · 129 KB
/
tartify
File metadata and controls
executable file
·3309 lines (2820 loc) · 129 KB
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
#!/bin/bash
##################################################################################
#
# Filename: tartify
#
# Description: BASH PS1 with GIT support
#
# Colored command prompt adapted to GIT repository. VERY
# colorfull, not for the faint hearted
#
# Configuration: place this file somewhere in your PATH and source it in your
# .bashrc
#
# source /path/to/bashps1
#
# Dependencies: Depends on GIT, might work on windows with Cygwin
#
# GVIM Version: 1.7+ (?)
#
# Author: Pierre Lhoste
# Twitter: http://twitter.com/peterhost
#
# Version: 0.1
# Created: 01.05.2011
# License: WTFPL V2
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long as
# the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND
# CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
#
#------------------------------------------------------------------------------
#
# USAGE : Just call the tartify() function from the command line
#
# You can also pass arguments to tartify() to make it display only
# certain informations
#
# tartify -h
#
# SEE ALSO :
#
# tartitune : tune tartify settings (colors, styles, ...)
#
# tartiforce : temporarilly force tartify output
#
#PS1="${__PS1NN_}${__PS1EMK_}[${__PS1UC_}\u${__PS1EMK_}@${__PS1EMUC_}\h ${__PS1C_}\${NEW_PWD}${__PS1EMK_}] \$"
#PROMPT_COMMAND=tartify
#
#
#
#------------------------------------------------------------------------------
#
# ISSUE :
#
# * conditionnal newline : if you need a multiline prompt, with the 'tartify'
# line only inserted if you're being in a 'git' repository, consider using a
# PROMPT_COMMAND like this :
#
# prompt_command(){
# ...
# tartify w
# }
# PROMPT_COMMAND=prompt_command
#
# The 'w' option to tartify issues a newline if the contents of \`tartify\`
# is not an empty string.
#
# ISSUE: Inside PS1, it will work too at the cost of inserting an extra
# whitespace after the newline (otherwise the newline will be striped)
#
#
# ALMOST WORKS :
# PS1='$(echo -ne "\n ")\[$(tput kbs)$\] '
#
# INDENTATION
# PS1='\[$(tput sc)\]\[\033[60C (`date "+%a, %b %d"`)\]\[$(tput rc)\]'
#
#
#
# * Line Wrapping Calculation
#
# The one thing (that I know of) which confuse line wrapping (when browsing
# command history with long lines, for ex) is non-printable characters
# (such as ansi escape color codes, cursor movement,...). So:
#
# 1 - non-printable characters in the PS1 variable have to be "escaped"
# by enclosing them between a pair of escaped brackets :
#
# \[\033[0;30m\] instead of \033[0;30m
#
# And this has to be done at PS1 definition-time, as PS1 is only assigned
# ONCE but evaluated at EACH PROMPT.
#
# 2 - function calls inside the PS1 variable that issue non-printable
# characters will confuse the prompt, naturally, if the said n-p-chars
# are not escaped IN the PS1 variable itself at assignement time. Example :
#
# PS1=">"
# > pwd
# /some/dir
# > myfunc(){ echo "\[\033[0;30m\]\$(pwd) > \[\033[0m\]"; }
# > myfunc
# \[\033[0;30m\]$(pwd) > \[\033[0m\]
#
# this will work
# > PS1=$(myfunc)
# /some/dir > echo $PS1
# \[\033[0;30m\]$(pwd) > \[\033[0m\]
# /some/dir > cd tmp
# /some/dir/tmp >
#
# this won't:
# /some/dir/tmp > PS1='$(myfunc)'
# \[\]stevejobs~ echo $PS1
# $(myfunc)
# As you can see in the latter, there are no escaped ansi codes
# whatsoever, just a function call. the prompt will print
# litterally '\[\033[0;30m\]' each time, as this escaped substring
# was not hardcoded in the PS1 variable at the time when it was
# assigned, but generated by a function call evaluated for each
# prompt, INSIDE the PS1 variable
# MORE: on the subject
# http://www.issociate.de/board/post/481503/bash_command_substitution,_functions_and_quoting_:_need_help.html
#
# Problem is : if a function used in the PS1 variable is to adapt it's colored
# output according to context, there is no way to hardcode that
# directly in $PS1 with the '\[' escapes.
#
# -> better use `printf` rather than `echo` (which somewhat sucks and which
# behaviour is inconsistant across shells and OSes)
#
# OR...
# -> need to be issued on a line prior to the last line of the prompt, with :
# * either \n insertion,
#
# PS1="\$(tartify)\n$ "
#
# * or use of the PROMPT_COMMAND environment variable
#
# __somefunc() {
# ...
# tartify
# ...
# }
# export PROMPT_COMMAND=__somefunc
# PS1=...
#
# otherwise they will confuse wrapping too. Hence, your PS1 better look
# something like :
#
#
#
# (SEE:http://hintsforums.macworld.com/archive/index.php/t-17068.html)
#
# * Quick n dirty benchmark
# loop over 1000 executions of `tartify` on a 3.06GHz Intel Core 2 Duo Imac
# without any further methodology
#
# **execution-time (ms)**
# _____________________________________________________________
# | REPO | TINY | SMALL | MEDIUM | LARGE |
# | | ms % | ms % | ms % | ms % |
# |___________|____________|___________|___________|____________|
# | remote | 48 25% | 59 29% | 92 27% | 93 23% |
# | 1 stash | 56 30% | 56 28% | 179 52% | 202 50% |
# | branch | 60 32% | 63 31% | 46 13% | 81 20% |
# | repo | 14 7% | 13 6% | 13 4% | 14 3% |
# | timelast | 11 6% | 11 5% | 12 3% | 12 3% |
# | | | | | |
# | total | 189 | 202 | 342 | 402 |
# | | | | | |
# | __git_ps1 | | | | 63 |
# | __git_ps1 | | | | |
# |shwupstream| | | 21 | 26 |
# |___________|____________|___________|___________|____________|
#
#
#------------------------------------------------------------------------------
#
# NOTA :
# Special Character Codes
# \a – an ASCII bell character (07)
# \d – the date in “Weekday Month Date” format (e.g., “Tue May 26″)
# \D{format} – the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
# \e – an ASCII escape character (033) (hence : \e and \033 are equivalent)
# \h – the hostname up to the first `.’
# \H – the hostname
# \j – the number of jobs currently managed by the shell
# \l – the basename of the shell’s terminal device name
# \n – newline
# \r – carriage return
# \s – the name of the shell, the basename of $0 (the portion following the final slash)
# \t – the current time in 24-hour HH:MM:SS format
# \T – the current time in 12-hour HH:MM:SS format
# \@ – the current time in 12-hour am/pm format
# \A – the current time in 24-hour HH:MM format
# \u – the username of the current user
# \v – the version of bash (e.g., 2.00)
# \V – the release of bash, version + patchelvel (e.g., 2.00.0)
# \w – the current working directory
# \W – the basename of the current working directory
# \! – the history number of this command
# \# – the command number of this command
# \$ – if the effective UID is 0, a #, otherwise a $
# \nnn – the character corresponding to the octal number nnn
# \\ – a backslash
# \[ - begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
# \] – end a sequence of non-printing characters
#
# (http://www.wiredrevolution.com/bash-programming/customize-the-bash-ps1-command-prompt)
#TODO:
#
# * WARN: problem with auto-separator (gitps1) with 'tartiforce qNBRSL'
#------------------------------------------------------------------------------
#
# PRELIMINARY CHECKS
#
#------------------------------------------------------------------------------
# store command line params
__tartify_args="$*"
# Are we being sourced or executed ?
Prog="tartify"
__tartify_whocalled=
if [ "$(basename $0 2>/dev/null )" = "$Prog" ]; then
__tartify_whocalled="exec"
else
__tartify_whocalled="source"
fi
# take care of non UTF-8 terminals
supports8=
locale | grep -i utf-8 >/dev/null 2>&1 && supports8="true"
#------------------------------------------------------------------------------
#
# SHELL DETECTION (not used for the moment, planned ZSH support)
#
#------------------------------------------------------------------------------
## SHELL detection
## SHELL DARWIN LINUX
## sh path/to/sh sh
## csh -sh -sh
## tcsh -csh -csh
## ksh ksh ksh
## bash -bash bash
## zsh zsh zsh
#__thisShell=`ps $$ | grep $$ | awk '{ print $5 }' | sed 's/\-/\\\-/g'`
#echo $__thisShell
#__thisShell=$(basename $__thisShell)
#echo $__thisShell
## Darwin detection
#if uname -s | grep "Darwin" >/dev/null 2>&1
#then
# __OSflavor="Darwin" # macos
#fi
## BAIL if using SH on OSX, (scrambles "echo -ne" commands)
## (DEPRECATED, we use printf wherever possible)
#[ "$__OSflavor" = "Darwin" ] && [ "$__thisShell" = "sh" ] && { echo " SH detected, exit"; exit 1; }
#------------------------------------------------------------------------------
#
# MISC GLOBAL VARIABLES
#
#------------------------------------------------------------------------------
__tartify_define_colors_TPUT() {
# COLOR VARS : * declare those color codes ONCE and for ALL.
# This somewhat pollutes the GLOBAL SCOPE but the variable names
# are (thought to be) unique enough so that won't cause problems
#
# * do that like a grownup (tput, not ANSI escapes)
#
# * TODO: handle dark vs light background
#
# * TODO: handle 256 colors (if [ $(tput colors) -ge 256 ] ...)
# -> do that via tartitheme()
#
#ONLY DO THAT if not done anywhere else before when sourcing `.bashrc`
if [ "true" = "$__TPUT_COLORS_DEFINED" ]; then : ; else
# ANSI equivalent
# <attr> <fg> <bg>
# ALL
__NN_=$( tput sgr0 || : 2>/dev/null ) # [ 0m RESET ALL attributes
# STYLES
# <BEGIN>
__EM_=$( tput bold || : 2>/dev/null ) # [ 1m BEGIN DOUBLE INTENSITY (bold) mode
__DM_=$( tput dim || : 2>/dev/null ) # [ 2m BEGIN HALF INTENSITY (dim) mode
__UN_=$( tput smul || : 2>/dev/null ) # [ 4m BEGIN UNDESCORE (underlined) mode
__BL_=$( tput blink || : 2>/dev/null ) # [ 5m BEGIN BLINKING mode
__RV_=$( tput rev || : 2>/dev/null ) # [ 7m BEGIN REVERSE VIDEO (reverse) mode
__SO_=$( tput smso || : 2>/dev/null ) #?[ 7m BEGIN STANDOUT (reverse) mode
__IN_=$( tput invis || : 2>/dev/null ) # [ 8m BEGIN INVISIBLE mode
__DEL_=$(tput cub1 || : 2>/dev/null ) # MOVE cursor LEFT one space
# <END>
__SOQ_=$( tput rmso || : 2>/dev/null ) #?[ 27m END STANDOUT (reverse) mode
__UNQ_=$( tput rmul || : 2>/dev/null ) # [ 24m END UNDESCORE (underlined) mode
# for all other END style, use `tput sgr0` ($__NN_)
# COLORS
# <Foreground>
__K_=$( tput setf 0 || tput setaf 0 || : 2>/dev/null ) # [ 0m SET FG color to BLACK
__R_=$( tput setf 4 || tput setaf 1 || : 2>/dev/null ) # [ 1m SET FG color to RED
__G_=$( tput setf 2 || tput setaf 2 || : 2>/dev/null ) # [ 2m SET FG color to GREEN
__Y_=$( tput setf 6 || tput setaf 3 || : 2>/dev/null ) # [ 3m SET FG color to YELLOW
__B_=$( tput setf 1 || tput setaf 4 || : 2>/dev/null ) # [ 4m SET FG color to BLUE
__M_=$( tput setf 5 || tput setaf 5 || : 2>/dev/null ) # [ 5m SET FG color to MAGENTA
__C_=$( tput setf 3 || tput setaf 6 || : 2>/dev/null ) # [ 6m SET FG color to CYAN
__W_=$( tput setf 7 || tput setaf 7 || : 2>/dev/null ) # [ 7m SET FG color to WHITE
# <Background>
__BGK_=$( tput setb 0 || tput setab 0 || : 2>/dev/null ) # [ 0m SET BG color to BLACK
__BGR_=$( tput setb 4 || tput setab 1 || : 2>/dev/null ) # [ 1m SET BG color to RED
__BGG_=$( tput setb 2 || tput setab 2 || : 2>/dev/null ) # [ 2m SET BG color to GREEN
__BGY_=$( tput setb 6 || tput setab 3 || : 2>/dev/null ) # [ 3m SET BG color to YELLOW
__BGB_=$( tput setb 1 || tput setab 4 || : 2>/dev/null ) # [ 4m SET BG color to BLUE
__BGM_=$( tput setb 5 || tput setab 5 || : 2>/dev/null ) # [ 5m SET BG color to MAGENTA
__BGC_=$( tput setb 3 || tput setab 6 || : 2>/dev/null ) # [ 6m SET BG color to CYAN
__BGW_=$( tput setb 7 || tput setab 7 || : 2>/dev/null ) # [ 7m SET BG color to WHITE
# <reset>
__NF_=$( tput setf 9 || tput setaf 9 || : 2>/dev/null ) # [ 39m RESET FG color to term's default
__NG_=$( tput setb 9 || tput setab 9 || : 2>/dev/null ) # [ 49m RESET BG color to term's default
__NFG_=$__NF_$__NB_ # [ 39; 49m RESET FG & BG color to term's default
if [ $(tput colors) -eq 256 ]; then
## <Foreground>
__K_=$( tput setf 243 || tput setaf 243 || : 2>/dev/null ) # SET FG color to BLACK
# __R_=$( tput setf 196 || tput setaf 196 || : 2>/dev/null ) # SET FG color to RED
# __G_=$( tput setf 34 || tput setaf 34 || : 2>/dev/null ) # SET FG color to GREEN
# __Y_=$( tput setf 220 || tput setaf 220 || : 2>/dev/null ) # SET FG color to YELLOW
# __B_=$( tput setf 33 || tput setaf 33 || : 2>/dev/null ) # SET FG color to BLUE
# __M_=$( tput setf 201 || tput setaf 201 || : 2>/dev/null ) # SET FG color to MAGENTA
# __C_=$( tput setf 45 || tput setaf 45 || : 2>/dev/null ) # SET FG color to CYAN
# __W_=$( tput setf 15 || tput setaf 15 || : 2>/dev/null ) # SET FG color to WHITE
## <Background>
#__BGK_=$( tput setb 243 || tput setab 243 || : 2>/dev/null ) # SET BG color to BLACK
#__BGR_=$( tput setb 196 || tput setab 196 || : 2>/dev/null ) # SET BG color to RED
#__BGG_=$( tput setb 34 || tput setab 34 || : 2>/dev/null ) # SET BG color to GREEN
#__BGY_=$( tput setb 220 || tput setab 220 || : 2>/dev/null ) # SET BG color to YELLOW
#__BGB_=$( tput setb 33 || tput setab 33 || : 2>/dev/null ) # SET BG color to BLUE
#__BGM_=$( tput setb 201 || tput setab 201 || : 2>/dev/null ) # SET BG color to MAGENTA
#__BGC_=$( tput setb 45 || tput setab 45 || : 2>/dev/null ) # SET BG color to CYAN
#__BGW_=$( tput setb 15 || tput setab 15 || : 2>/dev/null ) # SET BG color to WHITE
fi
# <pseudo Foreground-bold>
__EMK_=$__EM_$__K_ # [ 1; 20m SET FG color to BOLD BLACK
__EMR_=$__EM_$__R_ # [ 1; 21m SET FG color to BOLD RED
__EMG_=$__EM_$__G_ # [ 1; 22m SET FG color to BOLD GREEN
__EMY_=$__EM_$__Y_ # [ 1; 23m SET FG color to BOLD YELLOW
__EMB_=$__EM_$__B_ # [ 1; 24m SET FG color to BOLD BLUE
__EMM_=$__EM_$__M_ # [ 1; 25m SET FG color to BOLD MAGENTA
__EMC_=$__EM_$__C_ # [ 1; 26m SET FG color to BOLD CYAN
__EMW_=$__EM_$__W_ # [ 1; 27m SET FG color to BOLD RED
#MISC (non color)
__NL_=$( tput cud1 )
fi
}
__tartify_reset_PS1_globs(){
local section=$1
if [ "NAME" = "$section" ] || [ -z "$section" ];then
__t4_rep="" # repo name
__t4_nrep="" # repo name with 'm/M' option
__t4_lpath="" # local path in repo with 'm/M' option
__t4_sepN="" # dynamic separator for repo name
__t4_ncrep="" # NOCOLORS repo name
fi
if [ "BRANCH" = "$section" ] || [ -z "$section" ];then
# T=untracked files t=no untracked files
# U=unstaged changes u=no unstaged changes
# S=staged changes s=no staged changes
# R=remote info r=no remote info
__t4_tU="" # Unstaged
__t4_tuSr="" # Staged (stag-before-rem
__t4_tRA="" # remote Ahead of
__t4_tRD="" # remote behinD
__t4_tRI="" # remote dIverged
__t4_tRO="" # remote Ok (uptodate)
__t4_tRN="" # remote None
__t4_turS="" # Staged (stag-before-rem
__t4_TU="" #UNtracked Unstaged
__t4_TuSr="" #UNtracked Staged (stag-before-rem
__t4_TRA="" #UNtracked remote Ahead of
__t4_TRD="" #UNtracked remote behinD
__t4_TRI="" #UNtracked remote dIverged
__t4_TRO="" #UNtracked remote Ok (uptodate)
__t4_TRN="" #UNtracked remote None
__t4_TurS="" #UNtracked Staged (rem-before-stag
__t4_sepB="" # dynamic separator for branch
__t4_merg="" # merge infos for branch
__t4_bare="" # bare repository indicator
__t4_ncbranch="" # NOCOLORS branch
__t4_ncmerg="" # NOCOLORS merge infos for branch
__t4_ncbare="" # NOCOLORS bare repository indicator
__t4_oldschool="" # OLDSCHOOL branch (__git_PS1)
fi
if [ "ANCESTOR" = "$section" ] || [ -z "$section" ];then
__t4_anc="" # name of parent repo in case of submodule
__t4_sepA="" # dynamic separator for ancestor
__t4_ncanc="" # NOCOLORS ancestor
fi
if [ "REMOTE" = "$section" ] || [ -z "$section" ];then
__t4_sepR="" # dynamic separator for remotes
__t4_rOrsep="" # dynamic inter-remotes separator
__t4_rOt="" # tracked marker for remotename 'origin'
__t4_rOn="" # marker for remotename 'origin'
__t4_rO1p="" # first paren for count of commits ahead/behind of remote for remotename 'origin'
__t4_rOac="" # nb of commits ahead of remote for remotename 'origin'
__t4_rOcsep="" # (optional) separator
__t4_rObc="" # nb of commits behind of remote for remotename 'origin'
__t4_rO2p="" # second paren for count of commits ahead/behind of remote for remotename 'origin'
__t4_rUrsep="" # dynamic inter-remotes separator
__t4_rUt="" # tracked marker for remotename 'upstream'
__t4_rUn="" # marker for remotename 'upstream'
__t4_rU1p="" # first paren for count of commits ahead/behind of remote for remotename 'upstream'
__t4_rUac="" # nb of commits ahead of remote for remotename 'upstream'
__t4_rUcsep="" # (optional) separator
__t4_rUbc="" # nb of commits behind of remote for remotename 'upstream'
__t4_rU2p="" # second paren for count of commits ahead/behind of remote for remotename 'upstream'
__t4_r1rsep="" # dynamic inter-remotes separator
__t4_r1t="" # tracked marker for 1ST remotename 'other'
__t4_r1n="" # marker for 1ST remotename 'other'
__t4_r11p="" # first paren for count of commits ahead/behind of remote for 1ST remotename 'other'
__t4_r1ac="" # nb of commits ahead of remote for 1ST remotename 'other'
__t4_r1csep="" # (optional) separator
__t4_r1bc="" # nb of commits behind of remote for 1ST remotename 'other'
__t4_r12p="" # second paren for count of commits ahead/behind of remote for 1ST remotename 'other'
__t4_r2rsep="" # dynamic inter-remotes separator
__t4_r2t="" # tracked marker for 2ND remotename 'other'
__t4_r2n="" # marker for 2ND remotename 'other'
__t4_r21p="" # first paren for count of commits ahead/behind of remote for 2ND remotename 'other'
__t4_r2ac="" # nb of commits ahead of remote for 2ND remotename 'other'
__t4_r2csep="" # (optional) separator
__t4_r2bc="" # nb of commits behind of remote for 2ND remotename 'other'
__t4_r22p="" # second paren for count of commits ahead/behind of remote for 2ND remotename 'other'
__t4_r3rsep="" # dynamic inter-remotes separator
__t4_r3t="" # tracked marker for 3RD remotename 'other'
__t4_r3n="" # marker for 3RD remotename 'other'
__t4_r31p="" # first paren for count of commits ahead/behind of remote for 3RD remotename 'other'
__t4_r3ac="" # nb of commits ahead of remote for 3RD remotename 'other'
__t4_r3csep="" # (optional) separator
__t4_r3bc="" # nb of commits behind of remote for 3RD remotename 'other'
__t4_r32p="" # second paren for count of commits ahead/behind of remote for 3RD remotename 'other'
__t4_ncremotes="" # NOCOLORS remotes
fi
if [ "STASH" = "$section" ] || [ -z "$section" ];then
__t4_st="" # stash nocount
__t4_ST="" # stash count
__t4_sepS="" # dynamic separator for stashes
__t4_ncstash="" # NOCOLORS stash no count
__t4_ncSTASH="" # NOCOLORS stash count
fi
if [ "LAST" = "$section" ] || [ -z "$section" ];then
__t4_sepL="" # dynamic separator for time-last-commit
__t4_lccan="" # Could Commit Activity None
__t4_lccal="" # Could Commit Activity Low
__t4_lccah="" # Could Commit Activity High
__t4_lscan="" # Should Commit Activity None
__t4_lscal="" # Should Commit Activity Low
__t4_lscah="" # Should Commit Activity High
__t4_lnhan="" # No Hurry Activity None
__t4_lnhal="" # No Hurry Activity Low
__t4_lnhah="" # No Hurry Activity High
__t4_nclast="" # NOCOLORS last
fi
[ -z "$section" ] && {
#NOTA : all variables named __t4_D*, where * is one or more numbers
# are dynamically generated at `tartify` evaluation time
# (reserved variables for user-supplied delimiters)
# 0-49 : reserved for COLORED prompt
# 50-99 : reserved for NOCOLORS prompt (tartify 'c' option)
#
# NB1: 50 delimiters should be plenty enough
# NB2: could have used loop
# for ((n=0;n<100;n++)); do eval "__t4_D$n=" ; done;
# but about 10 times slower
__t4_D0=; __t4_D1=; __t4_D2=; __t4_D3=; __t4_D4=;
__t4_D5=; __t4_D6=; __t4_D7=; __t4_D8=; __t4_D9=;
__t4_D10=; __t4_D11=; __t4_D12=; __t4_D13=; __t4_D14=;
__t4_D15=; __t4_D16=; __t4_D17=; __t4_D18=; __t4_D19=;
__t4_D20=; __t4_D21=; __t4_D22=; __t4_D23=; __t4_D24=;
__t4_D25=; __t4_D26=; __t4_D27=; __t4_D28=; __t4_D29=;
__t4_D30=; __t4_D31=; __t4_D32=; __t4_D33=; __t4_D34=;
__t4_D35=; __t4_D35=; __t4_D36=; __t4_D38=; __t4_D39=;
__t4_D40=; __t4_D41=; __t4_D42=; __t4_D43=; __t4_D44=;
__t4_D45=; __t4_D46=; __t4_D47=; __t4_D48=; __t4_D49=;
__t4_D50=; __t4_D51=; __t4_D52=; __t4_D53=; __t4_D54=;
__t4_D55=; __t4_D56=; __t4_D57=; __t4_D58=; __t4_D59=;
__t4_D60=; __t4_D61=; __t4_D62=; __t4_D63=; __t4_D64=;
__t4_D65=; __t4_D66=; __t4_D67=; __t4_D68=; __t4_D69=;
__t4_D70=; __t4_D71=; __t4_D72=; __t4_D73=; __t4_D74=;
__t4_D75=; __t4_D76=; __t4_D77=; __t4_D78=; __t4_D79=;
__t4_D80=; __t4_D81=; __t4_D82=; __t4_D83=; __t4_D84=;
__t4_D85=; __t4_D86=; __t4_D87=; __t4_D88=; __t4_D89=;
__t4_D90=; __t4_D91=; __t4_D92=; __t4_D93=; __t4_D94=;
__t4_D95=; __t4_D96=; __t4_D97=; __t4_D98=; __t4_D99=;
__t4_pwd=""
__t4_newline_before=""
__t4_newline_after=""
__t4_tune=""
__t4_force=""
}
}
__tartify_print_PS1_globs(){
# REPOSITORY NAME
echo "${__K_}__t4_rep=${__NN_}$__t4_rep" # repo name
echo "${__K_}__t4_sepN=${__NN_}$__t4_sepN" # dynamic separator for repo name
# BRANCH
#
echo "${__K_}__t4_tU=${__NN_}$__t4_tU"
echo "${__K_}__t4_tuSr=${__NN_}$__t4_tuSr"
echo "${__K_}__t4_tRA=${__NN_}$__t4_tRA"
echo "${__K_}__t4_tRD=${__NN_}$__t4_tRD"
echo "${__K_}__t4_tRI=${__NN_}$__t4_tRI"
echo "${__K_}__t4_tRO=${__NN_}$__t4_tRO"
echo "${__K_}__t4_tRN=${__NN_}$__t4_tRN"
echo "${__K_}__t4_turS=${__NN_}$__t4_turS"
echo "${__K_}__t4_TU=${__NN_}$__t4_TU"
echo "${__K_}__t4_TuSr=${__NN_}$__t4_TuSr"
echo "${__K_}__t4_TRA=${__NN_}$__t4_TRA"
echo "${__K_}__t4_TRD=${__NN_}$__t4_TRD"
echo "${__K_}__t4_TRI=${__NN_}$__t4_TRI"
echo "${__K_}__t4_TRO=${__NN_}$__t4_TRO"
echo "${__K_}__t4_TRN=${__NN_}$__t4_TRN"
echo "${__K_}__t4_TurS=${__NN_}$__t4_TurS"
echo "${__K_}__t4_sepB=${__NN_}$__t4_sepB"
echo "${__K_}__t4_merg=${__NN_}$__t4_merg"
echo "${__K_}__t4_bare=${__NN_}$__t4_bare"
#REMOTE
echo "${__K_}__t4_sepR=${__NN_}$__t4_sepR";
echo "${__K_}__t4_rOt=${__NN_}$__t4_rOt";
echo "${__K_}__t4_rOn=${__NN_}$__t4_rOn";
echo "${__K_}__t4_rO1p=${__NN_}$__t4_rO1p";
echo "${__K_}__t4_rOac=${__NN_}$__t4_rOac";
echo "${__K_}__t4_rOsep=${__NN_}$__t4_rOsep";
echo "${__K_}__t4_rObc=${__NN_}$__t4_rObc";
echo "${__K_}__t4_rO2p=${__NN_}$__t4_rO2p";
echo "${__K_}__t4_rUt=${__NN_}$__t4_rUt";
echo "${__K_}__t4_rUn=${__NN_}$__t4_rUn";
echo "${__K_}__t4_rU1p=${__NN_}$__t4_rU1p";
echo "${__K_}__t4_rUac=${__NN_}$__t4_rUac";
echo "${__K_}__t4_rUsep=${__NN_}$__t4_rUsep";
echo "${__K_}__t4_rUbc=${__NN_}$__t4_rUbc";
echo "${__K_}__t4_rU2p=${__NN_}$__t4_rU2p";
echo "${__K_}__t4_r1t=${__NN_}$__t4_r1t";
echo "${__K_}__t4_r1n=${__NN_}$__t4_r1n";
echo "${__K_}__t4_r11p=${__NN_}$__t4_r11p";
echo "${__K_}__t4_r1ac=${__NN_}$__t4_r1ac";
echo "${__K_}__t4_r1sep=${__NN_}$__t4_r1sep";
echo "${__K_}__t4_r1bc=${__NN_}$__t4_r1bc";
echo "${__K_}__t4_r12p=${__NN_}$__t4_r12p";
echo "${__K_}__t4_r2t=${__NN_}$__t4_r2t";
echo "${__K_}__t4_r2n=${__NN_}$__t4_r2n";
echo "${__K_}__t4_r21p=${__NN_}$__t4_r21p";
echo "${__K_}__t4_r2ac=${__NN_}$__t4_r2ac";
echo "${__K_}__t4_r2sep=${__NN_}$__t4_r2sep";
echo "${__K_}__t4_r2bc=${__NN_}$__t4_r2bc";
echo "${__K_}__t4_r22p=${__NN_}$__t4_r22p";
echo "${__K_}__t4_r3t=${__NN_}$__t4_r3t";
echo "${__K_}__t4_r3n=${__NN_}$__t4_r3n";
echo "${__K_}__t4_r31p=${__NN_}$__t4_r31p";
echo "${__K_}__t4_r3ac=${__NN_}$__t4_r3ac";
echo "${__K_}__t4_r3sep=${__NN_}$__t4_r3sep";
echo "${__K_}__t4_r3bc=${__NN_}$__t4_r3bc";
echo "${__K_}__t4_r32p=${__NN_}$__t4_r32p";
#STASH
echo "${__K_}__t4_st=${__NN_}$__t4_st"
echo "${__K_}__t4_ST=${__NN_}$__t4_ST"
echo "${__K_}__t4_sepS=${__NN_}$__t4_sepS"
#LAST COMMIT
echo "${__K_}__t4_sepL=${__NN_}$__t4_sepL"
echo "${__K_}__t4_lccan=${__NN_}$__t4_lccan"
echo "${__K_}__t4_lccal=${__NN_}$__t4_lccal"
echo "${__K_}__t4_lccah=${__NN_}$__t4_lccah"
echo "${__K_}__t4_lscan=${__NN_}$__t4_lscan"
echo "${__K_}__t4_lscal=${__NN_}$__t4_lscal"
echo "${__K_}__t4_lscah=${__NN_}$__t4_lscah"
echo "${__K_}__t4_lnhan=${__NN_}$__t4_lnhan"
echo "${__K_}__t4_lnhal=${__NN_}$__t4_lnhal"
echo "${__K_}__t4_lnhah=${__NN_}$__t4_lnhah"
#_t4_D*
echo "__t4_D0=$__t4_D0"; echo "__t4_D1=$__t4_D1"; echo "__t4_D2=$__t4_D2"; echo "__t4_D3=$__t4_D3"; echo "__t4_D4=$__t4_D4";
echo "__t4_D5=$__t4_D5"; echo "__t4_D6=$__t4_D6"; echo "__t4_D7=$__t4_D7"; echo "__t4_D8=$__t4_D8"; echo "__t4_D9=$__t4_D9";
echo "__t4_D10=$__t4_D10"; echo "__t4_D11=$__t4_D11"; echo "__t4_D12=$__t4_D12"; echo "__t4_D13=$__t4_D13"; echo "__t4_D14=$__t4_D14";
echo "__t4_D15=$__t4_D15"; echo "__t4_D16=$__t4_D16"; echo "__t4_D17=$__t4_D17"; echo "__t4_D18=$__t4_D18"; echo "__t4_D19=$__t4_D19";
echo "__t4_D20=$__t4_D20"; echo "__t4_D21=$__t4_D21"; echo "__t4_D22=$__t4_D22"; echo "__t4_D23=$__t4_D23"; echo "__t4_D24=$__t4_D24";
echo "__t4_D25=$__t4_D25"; echo "__t4_D26=$__t4_D26"; echo "__t4_D27=$__t4_D27"; echo "__t4_D28=$__t4_D28"; echo "__t4_D29=$__t4_D29";
echo "__t4_D30=$__t4_D30"; echo "__t4_D31=$__t4_D31"; echo "__t4_D32=$__t4_D32"; echo "__t4_D33=$__t4_D33"; echo "__t4_D34=$__t4_D34";
echo "__t4_D35=$__t4_D35"; echo "__t4_D35=$__t4_D35"; echo "__t4_D36=$__t4_D36"; echo "__t4_D38=$__t4_D38"; echo "__t4_D39=$__t4_D39";
echo "__t4_D40=$__t4_D40"; echo "__t4_D41=$__t4_D41"; echo "__t4_D42=$__t4_D42"; echo "__t4_D43=$__t4_D43"; echo "__t4_D44=$__t4_D44";
echo "__t4_D45=$__t4_D45"; echo "__t4_D46=$__t4_D46"; echo "__t4_D47=$__t4_D47"; echo "__t4_D48=$__t4_D48"; echo "__t4_D49=$__t4_D49";
echo "__t4_D50=$__t4_D50"; echo "__t4_D51=$__t4_D51"; echo "__t4_D52=$__t4_D52"; echo "__t4_D53=$__t4_D53"; echo "__t4_D54=$__t4_D54";
echo "__t4_D55=$__t4_D55"; echo "__t4_D56=$__t4_D56"; echo "__t4_D57=$__t4_D57"; echo "__t4_D58=$__t4_D58"; echo "__t4_D59=$__t4_D59";
echo "__t4_D60=$__t4_D60"; echo "__t4_D61=$__t4_D61"; echo "__t4_D62=$__t4_D62"; echo "__t4_D63=$__t4_D63"; echo "__t4_D64=$__t4_D64";
echo "__t4_D65=$__t4_D65"; echo "__t4_D66=$__t4_D66"; echo "__t4_D67=$__t4_D67"; echo "__t4_D68=$__t4_D68"; echo "__t4_D69=$__t4_D69";
echo "__t4_D70=$__t4_D70"; echo "__t4_D71=$__t4_D71"; echo "__t4_D72=$__t4_D72"; echo "__t4_D73=$__t4_D73"; echo "__t4_D74=$__t4_D74";
echo "__t4_D75=$__t4_D75"; echo "__t4_D76=$__t4_D76"; echo "__t4_D77=$__t4_D77"; echo "__t4_D78=$__t4_D78"; echo "__t4_D79=$__t4_D79";
echo "__t4_D80=$__t4_D80"; echo "__t4_D81=$__t4_D81"; echo "__t4_D82=$__t4_D82"; echo "__t4_D83=$__t4_D83"; echo "__t4_D84=$__t4_D84";
echo "__t4_D85=$__t4_D85"; echo "__t4_D86=$__t4_D86"; echo "__t4_D87=$__t4_D87"; echo "__t4_D88=$__t4_D88"; echo "__t4_D89=$__t4_D89";
echo "__t4_D90=$__t4_D90"; echo "__t4_D91=$__t4_D91"; echo "__t4_D92=$__t4_D92"; echo "__t4_D93=$__t4_D93"; echo "__t4_D94=$__t4_D94";
echo "__t4_D95=$__t4_D95"; echo "__t4_D96=$__t4_D96"; echo "__t4_D97=$__t4_D97"; echo "__t4_D98=$__t4_D98"; echo "__t4_D99=$__t4_D99";
echo "${__K_}__t4_newline_before=${__NN_}$__t4_newline_before"
echo "${__K_}__t4_newline_after=${__NN_}$__t4_newline_after"
echo "${__K_}__t4_tune=${__NN_}$__t4_tune"
echo "${__K_}__t4_force=${__NN_}$__t4_force"
}
__tartify_init_globs(){
# Internal (RESERVED)
export TARTIFY_OPTIONS_ELEMENTS='aAbBlLmMnNorRsS'
export TARTIFY_OPTIONS_MODES='0123456789pqv'
export TARTIFY_OPTIONS_MODIFIERS='cdfItwW'
export TARTIFY_OPTIONS_HELP='eh'
#export TARTIFY_OPTIONS="${TARTIFY_OPTIONS_ELEMENTS}${TARTIFY_OPTIONS_MODES}${TARTIFY_OPTIONS_MODIFIERS}${TARTIFY_OPTIONS_HELP}"
export TARTIFY_OPTIONS="0123456789aAbBcdefhIlLmMnNopqrRsStwW"
# External TARTIFY PARAMETERS : adapt to your needs
#-------------------------------------------------------
# GLOBAL
export TARTIFY_FORCE="" # A string containing tartify command-line params. If non empty, will
# overwrite any arguments the tartify command receives
export TARTIFY_STRING_MISC_SEPARATOR=" " # Default separator to be used with 'separator-less' tartify options
#-------------------------------------------------------
# TIME
# //COMMIT-WISE
export TARTIFY_SETTING_TIME_BUGME=TRUE # Non empty : will color and style the 'time since last commit' string
#TODO: MEDIUM
# which of the 4 elements (year, days, hour, minues) to display
export TARTIFY_SETTING_TIME_DISPLAY=LONG # LONG (min, hours, days) MEDIUM (2 elements) SHORT (1 element) CHAR (cf. next var)
[ "true" = $supports8 ] && {
export TARTIFY_STRING_TIME_CHARDISPLAY="⟳ " # String to display in case prec. var == CHAR
} || {
export TARTIFY_STRING_TIME_CHARDISPLAY="◉ " # String to display in case prec. var == CHAR
}
# Uncommited changes (staged, unstaged)
export TARTIFY_SETTING_TIME_COULDCOMMIT=14400 # * nb seconds after which you COULD commit (default is 4 hours)
export TARTIFY_SETTING_TIME_SHOULDCOMMIT=86400 # * Max nb seconds after which you SHOULD commit (default is 1 day)
# styles applied to the 'time elapsed since last commit'
# string, in case of uncommited changes
export TARTIFY_STYLE_TIME_COULDCOMMIT=${__UN_} # UNDERLINED
export TARTIFY_STYLE_TIME_SHOULDCOMMIT=${__EM_}${__UN_} # BOLD UNDERLINED
# //ACTIVITY-WISE
export TARTIFY_SETTING_TIME_LOWACTIVITY=604800 # * nb seconds after which ACTIVITY is considered low (default is 7 days)
export TARTIFY_SETTING_TIME_MEDIUMACTIVITY=86400 # * Max nb seconds after which ACTIVITY is considered medium (default is 1 day)
# colors applied to the 'time elapsed since last commit'
# string in case of no uncommited changes
export TARTIFY_COLOR_TIME_ACTIVITY_HIGH=${__G_} # GREEN
export TARTIFY_COLOR_TIME_ACTIVITY_LOW=${__Y_} # YELLOW
export TARTIFY_COLOR_TIME_ACTIVITY_NONE=${__R_} # RED
#-------------------------------------------------------
#BRANCH
export TARTIFY_STRING_BRANCH_DOTGIT="GIT_DIR!" # "branch name" replacement string for .git directory
export TARTIFY_STRING_BRANCH_BARE="BARE:" # "branch name" replacement string for bare .git directory
export TARTIFY_COLOR_BRANCH_BARE=$__EMW_ # "branch name" replacement string for bare .git directory
#Branch style : Untracked files
export TARTIFY_STYLE_BRANCH_UNTRACKED=${__UN_} # Untracked Files UNDERLINED
export TARTIFY_SETTING_BRANCH_UNTRAKEDLOCAL="" # If non-empty, the untracked markers show untracked files limited only
# to 'local directory', not the whole repository
# Branch COLOR : first 2 chars
export TARTIFY_COLOR_BRANCH_UNSTAGED=${__EMR_} # unstaged changes (first char) BOLD RED
export TARTIFY_COLOR_BRANCH_STAGED=${__EMM_} # staged changes (2nd char) BOLD MAGENTA
# Branch COLOR : remaining chars
export TARTIFY_COLOR_BRANCH_UPSTREAM_DIVERGE=${__K_} # tracked remot diverg from HEAD BOLD DARK GREY
export TARTIFY_COLOR_BRANCH_UPSTREAM_BEHIND=${__R_} # tracked remote ahead of HEAD RED
export TARTIFY_COLOR_BRANCH_UPSTREAM_AHEAD=${__Y_} # tracked remote behind HEAD YELLOW
export TARTIFY_COLOR_BRANCH_UPSTREAM_UPTODATE=${__G_} # tracked remote == HEAD GREEN
export TARTIFY_COLOR_BRANCH_UPSTREAM_NOTRACK=${__B_} # no remote tracking branch BLUE
# NB: this is also the color used when
# tartify does not display 'upstream' info in branch
export TARTIFY_COLOR_BRANCH_NOCOMMITYET=${__W_} # empty repo, no commit yet WHITE
export TARTIFY_COLOR_BRANCH_GITDIR=${__C_} # inside .git dir CYAN
#Branch color : additional info
export TARTIFY_COLOR_BRANCH_MERGEINFOS=${__RV_}${__EMR_} # color for the merge/rebase/cherry-pick/bisect status of current branch (if any)
# BOLD RED
# Tartify shows U (Unstaged state), S (Staged state) and P (uPstream state:
# ahead, behind, diverged, uptodate) directly in the branch name, with 3
# different colors. The order of these informations can be tuned for
# better readability
export TARTIFY_SETTING_BRANCH_STAGED_INFO= # empty -> (unstaged)UPSTREAM[staged]
# non-empty -> (unstaged)[staged]UPSTREAM
export TARTIFY_SETTING_BRANCH_STAGED_INFOLENGTH=2 # How many letters of resulting branchname are to be colored with
# the "unstaged" and "staged" marker colors
# NB: this number cannot exceed int(length /2), see below
# Example:
# () for unstaged, [] for staged, rest: upstream info
#
# $TARTIFY_SETTING_BRANCH_STAGED_INFO empty
# $TARTIFY_SETTING_BRANCH_STAGED_INFOLENGTH =
# 0 : master 1 : (m)aste[r] 2 : (ma)st[er] 3 : (mas)[ter] 4 : (mas)[ter] ,...
# 0 : feature 1 : (f)eatur[e] 2 : (fe)atu[re] 3 : (fea)t[ure] 4 : (fea)t[ure] ,...
#
# $TARTIFY_SETTING_BRANCH_STAGED_INFO non-empty
# $TARTIFY_SETTING_BRANCH_STAGED_INFOLENGTH =
# 0 : master 1 : (m)[a]ster 2 : (ma)[st]er 3 : (mas)[ter] 4 : (mas)[ter] ,...
#-------------------------------------------------------
# ANCESTOR
export TARTIFY_COLOR_ANCESTOR_NAME=${__EMM_} # parent repository's "name" MAGENTA
[ "true" = $supports8 ] && {
export TARTIFY_STRING_ANCESTOR_MARKER="↪" # if non empty, will replace the name of the parent repository
# in the 'ancestor' field in case of a submodule
} || {
export TARTIFY_STRING_ANCESTOR_MARKER=">"
}
export TARTIFY_STRING_ANCESTOR_NOSUB="X" # string output before ancestor repo's name in case sub-repo is
# a valid submodule
#-------------------------------------------------------
# REPOSITORY
export TARTIFY_COLOR_REPO_NAMEALONE=${__C_} # repository's "name" CYAN
export TARTIFY_COLOR_REPO_NAMEBASE=${__EMC_} # 'm/M' option : repository's "base-name" BOLD CYAN
export TARTIFY_COLOR_REPO_LOCALPATH=${__C_} # 'm/M' option : local path in repo repository CYAN
#-------------------------------------------------------
# REMOTES
# leave empty for PAREN, whitespace for NOPAREN
# (this because it's a bad idea to store a litteral
# paren in an environment variable)
export TARTIFY_STRING_REMOTE_1STPAREN="" # opening paren for remote ahead/behind count
export TARTIFY_STRING_REMOTE_2NDPAREN="" # opening paren for remote ahead/behind count
export TARTIFY_STRING_REMOTE_SEP=" " # (optionnal) separator between remotes
export TARTIFY_STRING_REMOTE_COUNTSEP="/" # separator for ahead/behind count
export TARTIFY_STRING_REMOTE_ORIGIN="O" # marker for remote repo called 'origin'
export TARTIFY_STRING_REMOTE_UPSTREAM="U" # marker for remote repo called 'upstream'
[ "true" = $supports8 ] && {
export TARTIFY_STRING_REMOTE_OTHER=" ⇧ " # generic marker for remote repo
export TARTIFY_STRING_REMOTE_TRACKING="➝ " # marker for tracked branch
} || {
export TARTIFY_STRING_REMOTE_OTHER="X " # generic marker for remote repo
export TARTIFY_STRING_REMOTE_TRACKING=">" # marker for tracked branch
}
export TARTIFY_COLOR_REMOTE_NAME_ORIGIN=${__G_} # color for origin remote marker GREEN
export TARTIFY_COLOR_REMOTE_NAME_UPSTREAM=${__M_} # color for upstream remote marker MAGENTA
export TARTIFY_COLOR_REMOTE_NAME_OTHER=${__Y_} # color for other remote marker YELLOW
export TARTIFY_COLOR_REMOTE_COUNT_AHEAD=${__G_} # nb commits ahead of remote GREEN
export TARTIFY_COLOR_REMOTE_COUNT_BEHIND=${__R_} # nb commits behind of remote RED
#-------------------------------------------------------
# STASH
export TARTIFY_SETTING_STASH_COUNT= # non empty: print 1 $TARTIFY_STRING_STASH per existing stash
# (WARN: this is slow process, add ~50ms computing time)
[ "true" = $supports8 ] && {
#export TARTIFY_STRING_STASH="☆ " # marker for stash
export TARTIFY_STRING_STASH="•" # marker for stash
} || {
export TARTIFY_STRING_STASH="*" # marker for stash
}
export TARTIFY_COLOR_STASH_NOCOUNT=${__Y_} # color when not counting YELLOW
export TARTIFY_COLOR_STASH_COUNT=${__EMY_} # color in "count mode" BOLD YELLOW
#-------------------------------------------------------
# UNPARSED CHARS
export TARTIFY_COLOR_MISC_DELIMITER=${__K_} # color for (unparsed) delimiters DIM GREY
#-------------------------------------------------------
# MENU
export TARTIFY_COLOR_MENU_BORDER=$__B_
[ "true" = $supports8 ] && {
export TARTIFY_STRING_MENU_TOPLEFT="┌"
export TARTIFY_STRING_MENU_TOP="─"
export TARTIFY_STRING_MENU_TOPRIGHT="┐"
export TARTIFY_STRING_MENU_LEFT="│"
export TARTIFY_STRING_MENU_RIGHT="│"
export TARTIFY_STRING_MENU_BOTTOMLEFT="└"
export TARTIFY_STRING_MENU_BOTTOM="─"
export TARTIFY_STRING_MENU_BOTTOMRIGHT="┘"
} || {
export TARTIFY_STRING_MENU_TOPLEFT=" "
export TARTIFY_STRING_MENU_TOP="_"
export TARTIFY_STRING_MENU_TOPRIGHT=" "
export TARTIFY_STRING_MENU_LEFT=" "
export TARTIFY_STRING_MENU_RIGHT=" "
export TARTIFY_STRING_MENU_BOTTOMLEFT=" "
export TARTIFY_STRING_MENU_BOTTOM="_"
export TARTIFY_STRING_MENU_BOTTOMRIGHT=" "
}
#-------------------------------------------------------
# SMART PWD
export TARTIFY_SETTING_PWD_MAXLEN=25 # ('d' option) How many characters of the $PWD should be kept
export TARTIFY_SETTING_REPO_NAMEMAXLEN=15 # ('m/M' option) How many characters of the $PWD should be kept
export TARTIFY_STRING_PWD_TRUNCSYMBOL='..' # ('d' option) Indicate that there has been dir truncation
export TARTIFY_COLOR_PWD=$__C_ # ('d' option) Color for PWD
}
__tartitune_init_globs(){
#-------------------------------------------------------
# GLOBAL
export TARTITUNE_SETTING_FORCE="false" # "true" : enter a tartitune session
}
#------------------------------------------------------------------------------
#
# ORIGINAL __git_ps1 FUNCTIONS (tuned to tartify)
#
#------------------------------------------------------------------------------
#
# following functions are copy/paste of the original functions from
# bash-completion.sh, slightly tuned for tartify.
#
# __tartify__git_ps1_find_upstream *CLONES* first part of __git_ps1_show_upstream
# __tartify_git_ps1_process_remote *CLONES* second part of __git_ps1_show_upstream
# __tartify_git_ps1 *CLONES* __git_ps1
#
# This, to ease keeping compatibility with original __git_ps1(), and to
# ease updates (at the cost of spaghettying tartify's code even more
# with dynamic variable scope *shit*)
#
# Modifications :
#
# * all local declarations moved to tartify(), as it's the root of our
# local dynamic scope
#
# Note: keep chunks of code in original order to ease diffing
__tartify_git_ps1_find_upstream () {
# fills the tartify() local variables :
# $upstream
# $verbose
# $legacy
# hack to restrain the following modification to this global variable
# to local dynamic scope, and set it to "auto" for all modes
# but __git_ps1 compatibility mode
local GIT_PS1_SHOWUPSTREAM=$GIT_PS1_SHOWUPSTREAM
[ "OLDSCHOOL" = "$branchstyle" ] || GIT_PS1_SHOWUPSTREAM="auto"
#[ "OLDSCHOOL" = "$branchstyle" ] || GIT_PS1_SHOWUPSTREAM="auto verbose"
# ----- BEGIN __git_ps1_show_upstream chunk -----
local key value
local svn_remote=() svn_url_pattern count n
#local upstream=git legacy="" verbose=""
# get some config options from git-config
while read key value; do
case "$key" in
bash.showupstream)
GIT_PS1_SHOWUPSTREAM="$value"
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]] && [ "OLDSCHOOL" = "$branchstyle" ]; then
p=""
return
fi
;;
svn-remote.*.url)
svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
svn_url_pattern+="\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
done <<< "$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
# parse configuration values
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
esac
done
# Find our upstream
case "$upstream" in
git) upstream="@{upstream}" ;;
svn*)
# get the upstream from the "git-svn-id: ..." in a commit message
# (git-svn uses essentially the same procedure internally)
local svn_upstream=($(git log --first-parent -1 \
--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
if [[ 0 -ne ${#svn_upstream[@]} ]]; then
svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
svn_upstream=${svn_upstream%@*}
local n_stop="${#svn_remote[@]}"
for ((n=1; n <= n_stop; ++n)); do
svn_upstream=${svn_upstream#${svn_remote[$n]}}
done
if [[ -z "$svn_upstream" ]]; then
# default branch name for checkouts with no layout:
upstream=${GIT_SVN_ID:-git-svn}
else
upstream=${svn_upstream#/}
fi
elif [[ "svn+git" = "$upstream" ]]; then
upstream="@{upstream}"
fi
;;
esac