-
Notifications
You must be signed in to change notification settings - Fork 0
/
passtore_static.sh
executable file
·2722 lines (2514 loc) · 101 KB
/
passtore_static.sh
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
#!/usr/bin/env bash
#
# Copyright 2023 Meik Michalke <[email protected]>
#
# passtore.sh is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# passtore.sh is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with passtore.sh. If not, see <http://www.gnu.org/licenses/>.
[[ "$1" =~ ^(--version)$ ]] && {
echo "2023-07-02";
exit 0
};
HAVE_PROFILE=false
HAVE_STORE_NAME=false
NEED_STORE_NAME=false
IMPORTKEYS=false
IMPORTKEYS_WKD=false
FETCHKEY=false
FILTERCONF=false
LIST_KEYS=false
LIST_PERSONS=false
LIST_EMAIL=false
LIST_GROUPS=false
LIST_STORES=false
LIST_PW_FROM_RW_STORE=false
SHORT_LIST=false
STORE_NAMES_ONLY=false
FILTER_LIST=false
UPDATE_RO_STORE=false
UPDATE_RW_STORE=false
MOVE_PASSWORD=false
SYNC_PASSWORD=false
GENERATE_PASSWORD_RO=false
GENERATE_PASSWORD_RW=false
PASS_GEN_OPTIONS="--clip"
MANUAL_PW_LENGTH=false
MANUAL_PW_CHARS=false
MANUAL_GPGHOME=false
MANUAL_ASCROOT=false
INTEGRITYCHECKS_RO=false
INTEGRITYCHECKS_RW=false
EDIT_YAML=false
SIGN_YAML=false
XTRA_SPACE=""
USERNAME=$(whoami)
USERHOME="${HOME}"
BSSHAREDIR="${USERHOME}/.config/bash_scripts_${USERNAME}/shared"
# DATE="$(date +%Y-%m-%d_%H-%M-%S)"
# OLDWD="$(pwd)"
# trap "cd ${OLDWD}" EXIT
### BEGIN DEPENDENCY SECTION ###
### BEGIN DEPENDENCY FILE func_check_tool.sh ###
check_tool ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "checks if the given tool is available
usage: check_tool [tool] [path]
[tool]: name of tool to look up
[path]: path to tool
if there's only one parameter, \"which\" is called and the result returned
if there's two, the functions exits silently if there are no errors
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "3";
return
};
local TNAME="$1";
local TPATH="$2";
if [ "${TPATH}" != "" ]; then
TOOL="${TPATH}";
else
TOOL="$(which ${TNAME})";
fi;
if [ -x "${TOOL}" ]; then
if [ "${TPATH}" == "" ]; then
echo "\"${TOOL}\"";
fi;
else
error "can't find ${TNAME}, please check your configuration!";
fi
}
### END DEPENDENCY FILE func_check_tool.sh ###
### BEGIN DEPENDENCY FILE func_warning.sh ###
warning ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: warning [message]";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "3";
return
};
echo -e "$(_orange_on_grey "warning:") $1"
}
### END DEPENDENCY FILE func_warning.sh ###
### BEGIN DEPENDENCY FILE func_appendconfig.sh ###
appendconfig ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "appends given text as a new line to given file
usage: appendconfig [path] [grep] [body] (extra) (comm)
[path]: file name, full path
[grep]: stuff to grep for in [path] to check whether the entry is already there
[body]: full line to append to [path] otherwise
(extra): one of:
- \"sudo\" if sudo is needed for the operation
- \"config\" to silence skips
- \"autoconfig\" for shorter syntax (assuming '^[grep]=' and '[grep]=')
(comm): an optional comment for the variable
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "8";
return
};
local FILEXISTS=false;
local ACPATH="$1";
local ACGREP="$2";
local ACBODY="$3";
local ACEXTRA="$4";
local ACCOMMENT="$5";
local ACGREPSHOW="${ACGREP}";
local SUDOCMD;
[[ "${ACCOMMENT}" != "" ]] && {
ACCOMMENT="# ${ACCOMMENT%\
}
"
};
if [[ "${ACEXTRA}" == "sudo" ]]; then
SUDOCMD="sudo";
sudo CONFFILE="${ACPATH}" bash -c '[[ -f "${CONFFILE}" ]]' && FILEXISTS=true;
else
[[ -f "${ACPATH}" ]] && FILEXISTS=true;
fi;
if [[ "${ACEXTRA}" == "autoconfig" ]]; then
ACBODY="${ACGREP}=${ACBODY}";
ACGREP="^${ACGREP}=";
fi;
if ${FILEXISTS}; then
if ! [[ -n $(${SUDOCMD} grep "${ACGREP}" "${ACPATH}") ]]; then
echo -en "appending $(_blue "${ACGREPSHOW}") to $(_blue "${ACPATH}")...";
if [[ "${ACEXTRA}" == "sudo" ]]; then
echo -e "${ACCOMMENT}${ACBODY}" | sudo tee --append "${ACPATH}" > /dev/null || error "failed!";
else
echo -e "${ACCOMMENT}${ACBODY}" >> "${ACPATH}" || error "failed!";
fi;
alldone;
else
if ! [[ "${ACEXTRA}" == "config" || "${ACEXTRA}" == "autoconfig" ]]; then
skip "appending to $(_blue "${ACPATH}") ($(_blue "${ACGREPSHOW}")), exists.";
fi;
fi;
else
skip "$(_blue "${ACPATH}") not found!";
fi
}
### END DEPENDENCY FILE func_appendconfig.sh ###
### BEGIN DEPENDENCY FILE func_yesno.sh ###
yesno ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: yesno [question] (yes) (no) (show)
returns true for yes or false for no
[question]: the question to ask
(yes): optional yes answer (default: \"[yY]\")
(no) optional no answer (default: \"[nN]\")
(show) optional string to show after question (default: \"(y/n)\")
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "1";
return
};
local ASK="$1";
local YES="$2";
[[ "${YES}" == "" ]] && YES="[yY]";
local NO="$3";
[[ "${NO}" == "" ]] && NO="[nN]";
local SHOW="$4";
[[ "${SHOW}" == "" ]] && SHOW="(y/n)";
local ANSWER;
local RESULT;
while true; do
read -p "$(_bold "${ASK}") $(_dgray "${SHOW}") " ANSWER;
case ${ANSWER} in
${YES})
RESULT=true 1>&2;
break
;;
${NO})
RESULT=false 1>&2;
break
;;
*)
echo -e $(_red "invalid response!") > 2
;;
esac;
done;
echo ${RESULT}
}
### END DEPENDENCY FILE func_yesno.sh ###
### BEGIN DEPENDENCY FILE func_edit_file.sh ###
edit_file ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "opens a file for editing if the correct argument is given
usage: edit_file [file] [arg_if] [arg] (error) (editor)
[file]: the file to open for editing
[arg_if]: the value of [arg] that launches the editor
[arg]: the argument to check
(error): optional custom error message
default: \"unable to edit file!\"
(editor): optional editor command to run
default: \"\${VISUAL:-\${EDITOR:-vi}}\"
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "1";
return
};
local EDITFILE="$1";
local ARG_IF="$2";
local ARG="$3";
local ERROR_MSG="$4";
local EDIT_CMD="$5";
[[ "${ERROR_MSG}" == "" ]] && ERROR_MSG="unable to edit file!";
[[ "${EDIT_CMD}" == "" ]] && EDIT_CMD="${VISUAL:-${EDITOR:-vi}}";
[[ "${ARG}" =~ ("${ARG_IF}") ]] && {
${EDIT_CMD} "${EDITFILE}" || error "${ERROR_MSG}";
exit 0
}
}
### END DEPENDENCY FILE func_edit_file.sh ###
### BEGIN DEPENDENCY FILE func_alldone.sh ###
alldone ()
{
[[ "$1" =~ ^(-h|--help)$ ]] && {
echo "usage: alldone";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "4";
return
};
_green ' ✔ '
}
### END DEPENDENCY FILE func_alldone.sh ###
### BEGIN DEPENDENCY FILE func_error.sh ###
error ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: error [message]";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "3";
return
};
echo -e "$(_lred "error:") $1";
exit 1
}
### END DEPENDENCY FILE func_error.sh ###
### BEGIN DEPENDENCY FILE func_min_version.sh ###
min_version ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "checks if the given command fulfills the minimum version requirement
usage: min_version [cmd] [arg] [min]
[cmd]: command to check
[arg]: argument to get the version info from [cmd]
[min]: the minimum version number that is required
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "1";
return
};
local CMD="$1";
local ARG="$2";
local MIN="$3";
[[ "${MIN}" == "" ]] && error "no minimum version info given!";
VERSION_FOUND="$(${CMD} ${ARG})";
[[ "${VERSION_FOUND}" -ge "${MIN}" ]] || error "need $(_blue "${CMD}") $(_green ">= ${MIN}") but only found version $(_red "${VERSION_FOUND}")!"
}
### END DEPENDENCY FILE func_min_version.sh ###
### BEGIN DEPENDENCY FILE func_mkmissingdir.sh ###
mkmissingdir ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: mkmissingdir [path] (extra) (mode)
[path]: the path to check and create (if missing)
(extra): the keyword \"sudo\" if mkdir needs root privileges (use \"none\" if you just need \"(mode)\")
(mode): file mode (as in chmod)
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "7";
return
};
local SUDOCMD="";
local MODECMD="";
if [[ "$2" == "sudo" ]]; then
SUDOCMD="sudo";
fi;
if [[ "$3" != "" ]]; then
MODECMD="--mode=$3";
fi;
if [ ! -d "${1}" ]; then
echo -en "create missing directory $(_blue "${1}")...";
${SUDOCMD} mkdir ${MODECMD} --parents "${1}" || error "failed!";
alldone;
fi
}
### END DEPENDENCY FILE func_mkmissingdir.sh ###
### BEGIN DEPENDENCY FILE func_skip.sh ###
skip ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: skip [message]";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "3";
return
};
echo -e "$(_green_on_grey "skipping:") $1"
}
### END DEPENDENCY FILE func_skip.sh ###
### BEGIN DEPENDENCY FILE func_path_exists.sh ###
path_exists ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: path_exists [test] [path] (show)
[test]: the test to perform (e.g., -d for dir, -f for file, see man test)
[path]: the path to check
(show): optional argument \"show\", if given [path] will be printed before the result
alternatively, use \"created\" to indicate that a currently missing path
will be created if needed
";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "5";
return
};
local TEST="$1";
local CHECKPATH="$2";
local SHOW="$3";
if [[ "${SHOW}" == "show" ]] || [[ "${SHOW}" == "created" ]]; then
[[ -n "${CHECKPATH}" ]] && echo -en "$(_blue "${CHECKPATH}") " || echo -en "$(_lgray "(empty)") ";
fi;
if [ ${TEST} "${CHECKPATH}" ]; then
_green '✔';
else
if [[ "${SHOW}" == "created" ]]; then
_orange '✖ (autocreate)';
else
_red '✖';
fi;
fi
}
### END DEPENDENCY FILE func_path_exists.sh ###
### BEGIN DEPENDENCY FILE colors_basic.sh ###
colors_basic ()
{
[[ "$1" =~ ^(-h|--help)$ ]] && {
echo "defines some basic colors and functions for text formatting
usage: colors_basic
use --colors to get a list of functions defined with colors_basic.sh.
";
return
};
[[ "$1" =~ ^(-c|--colors)$ ]] && {
echo "_bifulnc
_biulnc (deprecated)
_dgray (+bifulnc)
_lgray (+bifulnc)
_lred (+bifulnc)
_red (+bifulnc)
_lblue (+bifulnc)
_blue (+bifulnc)
_green (+bifulnc)
_lpurple (+bifulnc)
_purple (+bifulnc)
_black (+bifulnc)
_brown (+bifulnc)
_yellow (+bifulnc)
_orange (+bifulnc)
_cyan (+bifulnc)
_lcyan (+bifulnc)
_white (+bifulnc)
_green_on_grey (+bifulnc)
_orange_on_grey (+bifulnc)
_bg_red (+bifulnc)
_bg_green (+bifulnc)
_bold
_italic
_faint
_underscore
_blink
_inverse
_concealed (invisible)
_opt (+ifulnc; for option parameter names)
_arg (+bfulnc; for option arguments)
_path (+bifulnc; for path names)
_info (+bifulnc; for general info, e.g., configuration files)
_linfo (+bifulnc; for further infos to options, e.g., defaults)";
return
};
[[ "$1" =~ ^(-v|--version)$ ]] && {
echo "13";
return
};
TXT_DGRAY="[90m";
TXT_LGRAY="[38;5;248m";
TXT_LRED="[91m";
TXT_RED="[31m";
TXT_LBLUE="[94m";
TXT_BLUE="[34m";
TXT_LGREEN="[92m";
TXT_GREEN="[32m";
TXT_LPURPLE="[95m";
TXT_PURPLE="[35m";
TXT_BLACK="[30m";
TXT_BROWN="[33m";
TXT_YELLOW="[93m";
TXT_ORANGE="[38;5;202m";
TXT_CYAN="[36m";
TXT_LCYAN="[96m";
TXT_WHITE="[97m";
TXT_BOLD="[1m";
TXT_ITALIC="[3m";
TXT_FAINT="[2m";
TXT_UNDERSCORE="[4m";
TXT_BLINK="[5m";
TXT_INVERSE="[7m";
TXT_CONCEALED="[8m";
TXT_BG_RED="[41m";
TXT_BG_GREEN="[42m";
TXT_ORANGE_ON_GREY="[48;5;240;38;5;202m";
TXT_GREEN_ON_GREY="[48;5;240;38;5;040m";
OFF="[0m"
}
colors_basic
_bifulnc ()
{
[[ "$1" =~ ^(-h|--help)$ ]] && {
echo -e "activates ${TXT_BOLD}bold${OFF}, ${TXT_ITALIC}italics${OFF}, ${TXT_FAINT}faint${OFF}, ${TXT_UNDERSCORE}underscore${OFF}, ${TXT_BLINK}blink${OFF}, ${TXT_INVERSE}inverse${OFF}, or concealed (invisible),
if the letters b, i, f, u, l, n and/or c are given.
you shouldn't use this as a standalone function but inside color setting functions.
usage: _bifulnc \"[b|i|f|u|l|n|c]\"";
return
};
local CODE="";
[[ "$1" =~ "b" ]] && CODE="${CODE}${TXT_BOLD}";
[[ "$1" =~ "i" ]] && CODE="${CODE}${TXT_ITALIC}";
[[ "$1" =~ "f" ]] && CODE="${CODE}${TXT_FAINT}";
[[ "$1" =~ "u" ]] && CODE="${CODE}${TXT_UNDERSCORE}";
[[ "$1" =~ "l" ]] && CODE="${CODE}${TXT_BLINK}";
[[ "$1" =~ "n" ]] && CODE="${CODE}${TXT_INVERSE}";
[[ "$1" =~ "c" ]] && CODE="${CODE}${TXT_CONCEALED}";
echo -e "${CODE}"
}
_biulnc ()
{
_bifulnc $1
}
_dgray ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_DGRAY}[message]${OFF} in dark gray color
usage: _dgray \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_DGRAY}$(_bifulnc $2)$1${OFF}"
}
_lgray ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_LGRAY}[message]${OFF} in light gray color
usage: _lgray \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_LGRAY}$(_bifulnc $2)$1${OFF}"
}
_lred ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_LRED}[message]${OFF} in light red color
usage: _lred \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_LRED}$(_bifulnc $2)$1${OFF}"
}
_red ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_RED}[message]${OFF} in red color
usage: _red \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_RED}$(_bifulnc $2)$1${OFF}"
}
_lblue ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_LBLUE}[message]${OFF} in light blue color
usage: _lblue \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_LBLUE}$(_bifulnc $2)$1${OFF}"
}
_blue ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BLUE}[message]${OFF} in blue color
usage: _blue \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_BLUE}$(_bifulnc $2)$1${OFF}"
}
_green ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_GREEN}[message]${OFF} in green color
usage: _green \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_GREEN}$(_bifulnc $2)$1${OFF}"
}
_lpurple ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_LPURPLE}[message]${OFF} in light purple color
usage: _lpurple \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_LPURPLE}$(_bifulnc $2)$1${OFF}"
}
_purple ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_PURPLE}[message]${OFF} in purple color
usage: _purple \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_PURPLE}$(_bifulnc $2)$1${OFF}"
}
_black ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BLACK}[message]${OFF} in black color
usage: _black \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_BLACK}$(_bifulnc $2)$1${OFF}"
}
_brown ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BROWN}[message]${OFF} in brown color
usage: _brown \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_BROWN}$(_bifulnc $2)$1${OFF}"
}
_yellow ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_YELLOW}[message]${OFF} in yellow color
usage: _yellow \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_YELLOW}$(_bifulnc $2)$1${OFF}"
}
_orange ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_ORANGE}[message]${OFF} in orange color
usage: _orange \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_ORANGE}$(_bifulnc $2)$1${OFF}"
}
_cyan ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_CYAN}[message]${OFF} in cyan color
usage: _cyan \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_CYAN}$(_bifulnc $2)$1${OFF}"
}
_lcyan ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_LCYAN}[message]${OFF} in light cyan color
usage: _lcyan \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_LCYAN}$(_bifulnc $2)$1${OFF}"
}
_white ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_WHITE}[message]${OFF} in white color
usage: _white \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_WHITE}$(_bifulnc $2)$1${OFF}"
}
_green_on_grey ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_GREEN_ON_GREY}[message]${OFF} in green on grey color
usage: _green_on_grey \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_GREEN_ON_GREY}$(_bifulnc $2)$1${OFF}"
}
_orange_on_grey ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_ORANGE_ON_GREY}[message]${OFF} in orange on grey color
usage: _orange_on_grey \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_ORANGE_ON_GREY}$(_bifulnc $2)$1${OFF}"
}
_bg_red ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BG_RED}[message]${OFF} with red background color
usage: _bg_red \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_BG_RED}$(_bifulnc $2)$1${OFF}"
}
_bg_green ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BG_GREEN}[message]${OFF} with green background color
usage: _bg_green \"[message]\" (bifulnc)
[message]: the message to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_BG_GREEN}$(_bifulnc $2)$1${OFF}"
}
_bold ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BOLD}[message]${OFF} bold
usage: _bold \"[message]\"";
return
};
echo -e "${TXT_BOLD}$1${OFF}"
}
_italic ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_ITALIC}[message]${OFF} in italics
usage: _italic \"[message]\"";
return
};
echo -e "${TXT_ITALIC}$1${OFF}"
}
_faint ()
{
[[ "$1" == "" ]] && {
echo -e "prints faint ${TXT_FAINT}[message]${OFF}
usage: _faint \"[message]\"";
return
};
echo -e "${TXT_FAINT}$1${OFF}"
}
_underscore ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_UNDERSCORE}[message]${OFF} underscored
usage: _underscore \"[message]\"";
return
};
echo -e "${TXT_UNDERSCORE}$1${OFF}"
}
_blink ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_BLINK}[message]${OFF} blinking, only use with caution!
usage: _blink \"[message]\"";
return
};
echo -e "${TXT_BLINK}$1${OFF}"
}
_inverse ()
{
[[ "$1" == "" ]] && {
echo -e "prints ${TXT_INVERSE}[message]${OFF} inversed
usage: _inverse \"[message]\"";
return
};
echo -e "${TXT_INVERSE}$1${OFF}"
}
_concealed ()
{
[[ "$1" == "" ]] && {
echo -e "prints [message] concealed (invisible)
usage: _concealed \"[message]\"";
return
};
echo -e "${TXT_CONCEALED}$1${OFF}"
}
_opt ()
{
[[ "$1" == "" ]] && {
echo -e "prints an ${TXT_BOLD}[-o]${OFF} option
usage: _opt \"[-o]\" (ifulnc)
[-o]: the option to print
(iulnc): add \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible)); \"b\" ($(_bold "bold")) is active by default
";
return
};
echo -e "${TXT_BOLD}$(_bifulnc $2)$1${OFF}"
}
_arg ()
{
[[ "$1" == "" ]] && {
echo -e "prints an ${TXT_RED}${TXT_ITALIC}[<arg>]${OFF} option argument
usage: _arg \"[<arg>]\" (bfulnc)
[<arg>]: the option argument to print
(bulnc): add \"b\" ($(_bold "bold")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible)); \"i\" ($(_italic "italic")) is active by default
";
return
};
echo -e "${TXT_RED}${TXT_ITALIC}$(_bifulnc $2)$1${OFF}"
}
_path ()
{
[[ "$1" == "" ]] && {
echo -e "prints a ${TXT_BLUE}[path]${OFF}
usage: _path \"[path]\" (bifulnc)
[path]: the path to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_BLUE}$(_bifulnc $2)$1${OFF}"
}
_info ()
{
[[ "$1" == "" ]] && {
echo -e "prints some ${TXT_DGRAY}[info]${OFF}
usage: _info \"[info]\" (bifulnc)
[info]: the info to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_DGRAY}$(_bifulnc $2)$1${OFF}"
}
_linfo ()
{
[[ "$1" == "" ]] && {
echo -e "prints some ${TXT_LGRAY}[info]${OFF}
usage: _linfo \"[info]\" (bifulnc)
[info]: the info to print
(bifulnc): add \"b\" ($(_bold "bold")), \"i\" ($(_italic "italic")), \"f\" ($(_faint "faint")), \"u\" ($(_underscore "underscore")), \"l\" ($(_blink "blink")), \"n\" ($(_inverse "inverse")), or \"c\" (concealed, i.e. invisible))
";
return
};
echo -e "${TXT_LGRAY}$(_bifulnc $2)$1${OFF}"
}
### END DEPENDENCY FILE colors_basic.sh ###
### BEGIN DEPENDENCY FILE func_usage.sh ###
usage ()
{
[[ "$1" =~ ^(-h|--help)$ || "$1" == "" ]] && {
echo "usage: usage [section] [arg1] [arg2] [arg3] [arg4] [arg5]
[section]: one of
- \"usage\": usage info with section title (2 args)
- \"sect\": name of a section of options (2 args)
- \"opt\": an option with (optional) argument and description (3 args)
- \"default\": a default value after \"opt\" (1 arg)
- \"info\": additional info line after \"opt\" (5 args)
- \"note\": like \"info\", but the first arg is emphasized (5 args)
- \"par\": an additional parameter with explanation after \"opt\" (5 args)
- \"par_i\": additional info line after \"par\" (5 args)
- \"par_l\": additional list of infos after \"par\" (5 args)
- \"par_n\": like \"par_i\", but the first arg is emphasized (5 args)
- \"conf\": show configuration, version and dependencies info (5 args)
[arg1]: if usage: the command to document
if opt: the option to document
if sect: the name of the section
if default: the default value
if info: the info to show
if note: the emphasized info (e.g., \"note:\")
if par: the parameter name (e.g., a character)
if par_i: the info to show
if par_l: the info to show
if par_n: the emphasized info (e.g., \"note:\")
if conf: the configuration file or \"\"
[arg2]: if usage: the command options
if opt: an additional argument or \"\"
if sect: a line of additional info
if default: ignored
if info: a second line
if note: the info to show
if par: the parameter description
if par_i: a second line
if par_l: a second line
if par_n: the info to show
if conf: the version argument (e.g., \"--version\") or \"\"
[arg3]: if usage: ignored
if opt: description of the option
if sect: ignored
if default: ignored
if info: a third line
if note: a second line
if par: a second line
if par_i: a third line
if par_l: a third line
if par_n: a second line
if conf: the dependencies argument (e.g., \"--dependencies\") or \"\"
[arg4]: if usage: ignored
if opt: ignored
if sect: ignored
if default: ignored
if info: a fourth line
if note: a third line