-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
executable file
·7090 lines (6784 loc) · 216 KB
/
.bashrc
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
################################################################################
# bash configuration file
################################################################################
#>>> set -e # exit on any failure
#>>> set -u # exit on undeclared variables
#>>> set -o pipefail # return value of all commands in a pipe
#>>> set -x # command tracing
################################################################################
umask 027
unalias -a
set -o vi
shopt -s cdspell
shopt -s cmdhist
shopt -s extglob
shopt -s histappend
shopt -s histreedit
shopt -s histverify
shopt -s lithist
eval $(dircolors 2>/dev/null)
if [[ "${-}" == *(*)i*(*) ]]; then
setterm -blank 10 2>/dev/null
setterm -blength 0 2>/dev/null
fi
if [[ -f /etc/profile.d/bash-completion.sh ]]; then
source /etc/profile.d/bash-completion.sh
fi
complete -d -o dirnames cd
########################################
if [[ "${-/i}" != "${-}" ]] &&
[[ -x /usr/bin/fortune ]]; then
echo -en "\n"
fortune -ac all
fi
########################################
export HOME="$(realpath ${HOME})"
if [[ "${-/i}" != "${-}" ]]; then
mkdir -p ${HOME}/.history/screen 2>/dev/null
mkdir -p ${HOME}/.history/shell 2>/dev/null
export SCREENDIR="${HOME}/.screen"
mkdir -p ${SCREENDIR} 2>/dev/null
chown -R ${USER}:root ${SCREENDIR} 2>/dev/null
chmod -R 700 ${SCREENDIR} 2>/dev/null
fi
################################################################################
# variables
################################################################################
export _BASHED="true"
unset _SELF
unset SCRIPT
if [[ "${-/i}" == "${-}" ]]; then
export _SELF="$(realpath -- "${0}")"
export SCRIPT="$(basename -- "${_SELF}")"
fi
export UNAME="$(uname -s)"
if [[ -n "$(uname -a | grep -i "Microsoft")" ]]; then
UNAME="Windows"
fi
export COMPOSER="/.g/_data/zactive/coding/composer/Makefile"; alias composer="make -f ${COMPOSER}"
export PIMDIR="/.g/_data/zactive/_pim"
export NULLDIR="/.g/_data/zactive/_zcache"
export MAILDIR="${HOME}/Maildir"
export MAILCAPS="${HOME}/.mailcap"
export GDRIVE_REMOTE="gdrive"
export TODOS_MD_FORMAT="docx"
export TODOS_MD_TEXT="_todo.md"
export TODOS_MD="/.g/_data/zactive/_drive/_todo.docx"; export TODOS_MD_ID="gdrive:_todo.docx" #>>> 1AXaQYxKJCi_p8mZIGmZOexKm3liaoH4p9JoweJUjedM
export NOTES_MD="/.g/_data/zactive/_pim/tasks.notes.md"; export NOTES_MD_ID="gdrive:_notes.md" #>>> 1asjTujzIRYBiqvXdBG34RD_fCN7GQN5e
export IDEAS_MD="/.g/_data/zactive/writing/_imagination.md"; export IDEAS_MD_ID="gdrive:_write.md" #>>> 1_p06qeX31eFRTUJ2VKWhdfGUhaQBqF5k
export SALES_MD="/.g/_data/zactive/_pim/zoho.today.md"; #>>>export SALES_MD_ID="" #>>> 1wQrnTw0I5pDfzlqeuKdBNCNvFH9Ifulz
########################################
export LANG="en_US.UTF-8"
export LC_ALL="${LANG}"
export LC_COLLATE="C"
#>>>export LC_TIME="en_DK.UTF-8"
export LC_ALL=
export HISTFILE="${HOSTNAME}.${USER}.$(basename ${SHELL}).$(date +%Y-%m)"
export HISTFILE="${HOME}/.history/shell/${HISTFILE}"
export HISTSIZE="$(( (2**31)-1 ))"
export HISTFILESIZE="${HISTSIZE}"
export HISTTIMEFORMAT="%Y-%m-%dT%H:%M:%S "
export HISTCONTROL=
export HISTIGNORE=
########################################
#>>>export CARCH="i686"
#>>>export CHOST="i686-pc-linux-gnu"
export CARCH="x86_64"
export CHOST="x86_64-pc-linux-gnu"
#>>>export CFLAGS="-march=i686 -mtune=i686 -m32 -O2 -ggdb -pipe"
#>>>export CFLAGS="-march=core2 -mtune=core2 -m64 -O2 -ggdb -pipe"
#>>>export CFLAGS="-march=core2 -mtune=core2 -O2 -pipe"
export CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed"
export MAKEFLAGS="-j21"
export CCACHE_DIR="/tmp/.ccache"
########################################
export CDPATH=".:${HOME}"
export CDPATH+=":/.g"
export CDPATH+=":/.g/_data"
export CDPATH+=":/.g/_data/media"
export CDPATH+=":/.g/_data/zactive"
export PATH="${HOME}"
export PATH+=":${HOME}/commands"
export PATH+=":${HOME}/scripts"
if [[ "${UNAME}" == "Darwin" ]]; then
export PATH+=":/opt/local/libexec/gnubin"
export PATH+=":/opt/local/bin"
export PATH+=":/opt/local/sbin"
export PATH+=":/Library/Developer/CommandLineTools/usr/bin"
export PATH+=":/Library/Apple/usr/bin"
fi
if [[ -d /data/data/com.termux/files ]]; then
export PATH+=":/data/data/com.termux/files/usr/bin"
export PATH+=":/data/data/com.termux/files/usr/bin/applets"
fi
export PATH+=":/usr/local/bin"
export PATH+=":/usr/local/sbin"
export PATH+=":/usr/bin"
export PATH+=":/usr/sbin"
export PATH+=":/bin"
export PATH+=":/sbin"
export PATH+=":/usr/games/bin"
if [[ ${UNAME} == "Windows" ]]; then
export PATH+=":/mnt/c/WINDOWS"
export PATH+=":/mnt/c/WINDOWS/system32"
fi
if [[ -n ${CYGWIN} ]] || [[ -n ${CYGWIN_ROOT} ]]; then
export PATH+=":/c/WINDOWS"
export PATH+=":/c/WINDOWS/system32"
fi
########################################
# title escapes
# screen ESC k ${TITLE} ESC \
# xterm ESC ]0; ${TITLE} BEL
# color escapes
# ansi ESC [ ${0=normal,1=bold,7=reverse} ; ${30-37=color} m
# escape codes
# ESC \e
# BEL \a
export PROMPT_DIRTRIM=
declare PROMPT_SCR_COLOR="r"
declare PROMPT_TOKEN_CLR="\[\e[7;31m\]"
declare PROMPT_TOKEN_DFL="\[\e[0m\]" # reset color
declare PROMPT_TOKEN_PWD="\w"
if [[ ${HOSTNAME} == phoenix ]] ||
[[ ${HOSTNAME} == spider ]]; then
PROMPT_TOKEN_CLR="\[\e[7;32m\]"
PROMPT_SCR_COLOR="g"
elif [[ ${HOSTNAME} == shadow ]] ||
[[ ${HOSTNAME} == bastion ]]; then
PROMPT_TOKEN_CLR="\[\e[7;33m\]"
PROMPT_SCR_COLOR="y"
elif [[ ${HOSTNAME} == tarantula ]] ||
[[ ${HOSTNAME} == phantom ]]; then
PROMPT_TOKEN_CLR="\[\e[7;36m\]"
PROMPT_SCR_COLOR="c"
elif [[ ${HOSTNAME} == Arachnid ]]; then
PROMPT_TOKEN_CLR="\[\e[7;35m\]"
PROMPT_SCR_COLOR="m"
fi
declare PRE_PROMPT='\
\e]0;\
${PROMPT_KEY}[ ${TERM} | ${USER}@${HOSTNAME/%.*} | ${PWD/#$HOME/~} ]\
\a'
if { [[ -n ${CYGWIN} ]] || [[ -n ${CYGWIN_ROOT} ]]; } &&
{ [[ -z ${PROMPT} ]] || [[ ${PROMPT} == \$P\$G ]]; }; then
export PROMPT="cygwin"
fi
if [[ -d /data/data/com.termux/files ]] &&
[[ -z ${PROMPT} ]]; then
export PROMPT="android"
fi
if [[ ${PROMPT} == simple ]]; then
export PROMPT=
PROMPT_TOKEN_PWD="<\W>"
fi
if [[ -z ${PROMPT} ]]; then
export PROMPT=
export PROMPT_KEY=
else
export PROMPT="${PROMPT}"
export PROMPT_KEY="( ${PROMPT} )"
fi
if [[ "${SCRIPT}" != ".bashrc" ]]; then
export PROMPT_COMMAND="IMPERSONATE_MODE=\"true\"; echo -en \"${PRE_PROMPT}\";"
fi
if [[ -n ${PROMPT_KEY} ]] &&
[[ "${SCRIPT}" != ".bashrc" ]] &&
[[ ${BASH_EXECUTION_STRING/%\ *} != rsync ]] &&
[[ ${BASH_EXECUTION_STRING/%\ *} != scp ]] &&
[[ ${BASH_EXECUTION_STRING/%\ *} != unison ]]; then
eval "echo -en \"${PRE_PROMPT}\""
fi
# https://superuser.com/questions/175799/does-bash-have-a-hook-that-is-run-before-executing-a-command
# https://stackoverflow.com/questions/23033502/what-is-the-bash-variable-comp-line-and-what-does-it-do#23036401
# https://hints.macworld.com/dlfiles/preexec.bash.txt
export IMPERSONATE_NAME
export IMPERSONATE_MODE="false"
export IMPERSONATE_QUIT="shopt -u extdebug; trap - DEBUG;"
export IMPERSONATE_TRAP="shopt -s extdebug; trap impersonate_shell DEBUG;"
eval ${IMPERSONATE_QUIT}
if [[ ${PROMPT} == [+]*(*) ]]; then
export IMPERSONATE_NAME="${PROMPT/#+}"
PROMPT_TOKEN_PWD="\[\e[7;37m\](${IMPERSONATE_NAME}:\W)${PROMPT_TOKEN_DFL}"
history -a
HISTFILE="${HOSTNAME}.${USER}.${IMPERSONATE_NAME}.$(date +%Y-%m)"
HISTFILE="${HOME}/.history/shell/${HISTFILE}"
history -r
function impersonate_command { return 0; }
function impersonate_shell {
if [[ -n ${COMP_LINE} ]] ||
(( ${BASH_SUBSHELL} > 0 )) ||
[[ ${BASH_COMMAND} == IMPERSONATE_MODE[=]\"true\" ]] ||
[[ ${BASH_COMMAND} == echo*(*){PROMPT_KEY}*(*) ]] ||
[[ ${BASH_COMMAND} == shopt*(*) ]] ||
[[ ${BASH_COMMAND} == trap*(*) ]] ||
! ${IMPERSONATE_MODE}
then
return 0
else
IMPERSONATE_MODE="false"
fi
if [[ ${BASH_COMMAND} == [:]*(*) ]]; then
${BASH_COMMAND/#:}
elif [[ ${BASH_COMMAND} == [.]*(*) ]]; then
impersonate_command ${BASH_COMMAND/#.}
else
${IMPERSONATE_NAME} ${BASH_COMMAND}
fi
return 1
}
alias quit="${IMPERSONATE_QUIT} history -a; prompt; history -r;"
eval ${IMPERSONATE_TRAP}
fi
export PS1="\u@\h:\w\\$ "
export PS1="\
\n\
${PROMPT_TOKEN_CLR}\
[\u@\h]:[\D{%a/%j_%FT%T%z}]\
\n\
[\#/\!]\
${PROMPT_TOKEN_DFL}\
\[\ek\e\\\\\]:${PROMPT_TOKEN_PWD}\\$"
################################################################################
# commands
################################################################################
export NICELY="sudo -E ionice -c 2 -n 7 -t nice -n 19" ; alias nicely="${NICELY}"
export REALTIME="sudo -E ionice -c 1 -n 0 -t nice -n -20" ; alias realtime="${REALTIME}"
if {
[[ ${UNAME} == "Windows" ]] ||
{ [[ -n ${CYGWIN} ]] || [[ -n ${CYGWIN_ROOT} ]]; } ||
[[ "${UNAME}" == "Darwin" ]] ||
[[ -d /data/data/com.termux/files ]] ||
[[ ! -x $(which sudo 2>/dev/null) ]] ||
[[ ! -x $(which ionice 2>/dev/null) ]] ||
[[ ! -x $(which nice 2>/dev/null) ]];
}; then
export NICELY=
export REALTIME=
fi
#>>> export NICELY= ; unalias nicely
#>>> export REALTIME= ; unalias realtime
########################################
export MORE="less -rX" ; alias more="${MORE}"
export VI="${REALTIME} vim -u ${HOME}/.vimrc -i NONE -p" ; alias vi="${VI}"
export GVI="prompt -d -x ; ${VI} -g" ; alias gvim="${GVI}"
export VIEW="${VI}" ; alias view="${VIEW}"
if [[ "${-/i}" != "${-}" ]]; then
export PAGER=
export EDITOR=
export VISUAL=
fi
export PAGER="${PAGER:-${MORE}}"
export EDITOR="${EDITOR:-${VI}}"
export VISUAL="${EDITOR:-${VI}}"
########################################
export CP="cp -pvR" ; alias cp="${CP}"
export GREP="grep --color=auto -E" ; alias grep="${GREP}"
export LN="ln -fsv" ; alias ln="${LN}"
export MKDIR="mkdir -pv" ; alias mkdir="${MKDIR}"
export MV="mv -v" ; alias mv="${MV}"
export PS="ps u -ww --sort=pid -e" ; alias psl="${PS/ -ww}"
export RM="rm -frv" ; alias rm="${RM}"
export RMDIR="rmdir -v" ; alias rmdir="${RMDIR}"
export SED="sed -r" ; alias sed="${SED}"
if [[ -n ${CYGWIN} ]] || [[ -n ${CYGWIN_ROOT} ]]; then
unalias sed
fi
########################################
export LS="ls --color=auto --time-style=long-iso" ; alias ls="${LS}"
export LL="${LS} -asF -l" ; alias ll="${LL}"
export LX="${LS} -asF -kC" ; alias lx="${LX}"
export DU="du -b --time --time-style=long-iso" ; alias du="${DU}"
export LU="${DU} -cms -L {.[^.],}* 2>/dev/null | sort -nr" ; alias lu="${LU/ -L}"; alias llu="${LU}"
export NCDU="ncdu --confirm-quit -2 -rr -x -e" ; alias ncdu="(sleep 2 && echo cmgg &); ${NCDU}"
export RM_ALL="${RM} {.[^.],}*" ; alias rm-all="${RM_ALL}"
########################################
export CVS="reporter cvs" ; alias cvs="${CVS}"
export SVN="reporter svn" ; alias svn="${SVN}"
export SVNSYNC="reporter svnsync" ; alias svnsync="${SVNSYNC}"
export GIT_TRACE="1"
export GIT_CMD="git"
export GIT="reporter ${GIT_CMD}" #>>> ; alias git="${GIT}"
export GIT_ADD="${GIT} add --verbose --all" ; alias git-add="${GIT_ADD}"
export GIT_CMT="${GIT} commit --verbose" ; alias git-commit="${GIT_CMT}"
export GIT_STS="${GIT} status" ; alias git-status="${GIT_STS}"
export GIT_SVN="${GIT} svn" ; alias git-svn="${GIT_SVN}"
export DIFF_OPTS="-u -U10"
export GIT_DIF="--find-renames --full-index --summary --stat=128,128"
export GIT_FMT="${GIT_DIF} --pretty=fuller --date=iso --decorate"
export GIT_PAT="${GIT_DIF} --attach --binary --keep-subject"
########################################
export HTOPRC="${HOME}/.htoprc"
alias htop="${CP} -L ${HOME}/.htoprc.bak ${HOME}/.htoprc ; htop"
export LAST="last --system --fullnames --fulltimes --hostlast --ip" ; alias last="${LAST}"
export PV="pv --cursor --bytes --timer --progress --eta --rate --average-rate" ; alias pv="${PV}"
export XARGS="xargs --max-procs=2 --max-args=10" ; alias xargs="${XARGS}"
export XPDF="sudo -H -u plastic DISPLAY=:0 firefox" ; alias xpdf="${XPDF}"
export XPDF_READ="qpdfview" ; alias xpdf-read="${XPDF_READ}"
#>>>export RDP="rdesktop -z -n NULL -g 1024x768 -a 24 -r sound:remote" ; alias rdp="${RDP}"
#>>>export RDP="xfreerdp /dynamic-resolution /sound:sys:alsa" ; alias rdp="${RDP}"
export RDP="xfreerdp /dynamic-resolution /sound" ; alias rdp="${RDP}"
export VNC="vncviewer -Shared -FullColor" ; alias vnc="${VNC}"
export X2VNC="x2vnc -west -tunnel -shared -noblank -lockdelay 60 -timeout 60" ; alias x2vnc="${X2VNC}"
export XPRA="xpra attach --socket-dir=/tmp/xpra" ; alias xpra="${XPRA}"
#>>>export VLC="vlc --intf ncurses --no-color" ; alias vlc-c="${VLC}"
export VLC="vlc --intf ncurses --no-color --no-playlist-tree" ; alias vlc-c="${VLC}"
########################################
unset EMERGE_DEFAULT_OPTS
export EMERGE="prompt -z emerge \
--tree \
--unordered-display \
--deep \
--newuse \
--update \
--selective=n \
"
alias emerge="${EMERGE}"
########################################
export ENCFS6_CONFIG="${ENCFS6_CONFIG:-/.g/_data/zactive/.static/.encfs/encfs6.primary.xml}"
export ENCFS_FILE="${ENCFS6_CONFIG/%xml/asc}"
#>>> --verbose \
#>>> --idle=60 \
export ENCFS="encfs \
--nocache \
--standard \
--no-default-flags \
--public \
"
alias encfs="${ENCFS}"
########################################
export UNISON="/.g/_data/-track/-unison"
export UNISON_LOG="_log"
export UNISON_W="reporter unison \
-ui text \
-log \
-logfile ${UNISON}/${UNISON_LOG} \
-times \
-perms 0"
export UNISON_U="${UNISON_W} \
-perms -1 \
-numericids \
-owner \
-group"
export UNISON_F="${UNISON_U} \
-fastcheck=false \
"
alias unison="${UNISON_U}"
########################################
export RSYNC_C="reporter rsync \
-vv \
--rsh=ssh \
--recursive \
--one-file-system \
--itemize-changes \
--progress \
--compress \
--fuzzy \
--times \
"
export RSYNC_W="${RSYNC_C} \
--force \
--delete \
--delete-during \
"
export RSYNC_U="${RSYNC_W} \
--sparse \
--devices \
--specials \
--hard-links \
--links \
--perms \
--numeric-ids \
--owner \
--group \
"
export RSYNC_F="${RSYNC_U} \
--checksum \
"
export RSYNC_W="${RSYNC_W} \
--modify-window=10 \
"
alias rsync="${RSYNC_U}"
########################################
export RCLONE_C="reporter rclone"
#>> -vv \
#>>> --fast-list \
export RCLONE_U="${RCLONE_C} \
-v \
--config ${HOME}/.rclone.conf \
--progress \
--one-file-system \
--stats=0 \
--stats-file-name-length=0 \
--delete-during \
--track-renames \
--copy-links \
"
alias rclone="${RCLONE_U}"
########################################
export WGET_C="wget \
--verbose \
--progress=bar \
--execute robots=off \
--restrict-file-names=windows \
--no-check-certificate \
--server-response \
--adjust-extension \
--timestamping \
--timeout=3 \
--tries=3 \
--waitretry=3 \
"
export WGET_S="${WGET_C} \
--force-directories \
--no-host-directories \
--no-parent \
--page-requisites \
--convert-links \
--backup-converted \
"
export WGET_R="${WGET_S} \
--user-agent=Mozilla/5.0 \
--recursive \
--level=inf \
--random-wait \
--wait=3 \
"
alias wget="${WGET_C}"
########################################
export LINKS_C="links \
-download-dir ${NULLDIR} \
-download-utime 1 \
-aggressive-cache 1 \
-save-url-history 1 \
"
export LINKS="${LINKS_C} \
-menu-font-size 16 \
-html-user-font-size 16 \
-html-g-background-color 0x808080 \
-html-g-text-color 0x000000 \
-html-g-link-color 0x800000 \
-scroll-bar-frame-color 0x404040 \
-scroll-bar-area-color 0x808080 \
-scroll-bar-bar-color 0x404040 \
-menu-background-color 0x404040 \
-menu-foreground-color 0x808080 \
"
#>>>alias links="${LINKS} http://www.duckduckgo.com"
alias links="${LINKS}"
################################################################################
# aliases
################################################################################
alias halt="sudo runit-init 0"
alias reboot="sudo runit-init 6"
########################################
alias a="alias"
alias c="clear"
alias h="history"
alias hg="history | ${GREP}"
########################################
alias cl="clear ; ${LL}"
alias ztmp="cd /tmp ; clear ; ${LL}"
alias zpim="cd ${PIMDIR} ; clear ; ${LL} ; git-status"
alias zcode="cd /.g/_data/zactive/coding ; clear ; ${LL}"
alias zwrite="cd /.g/_data/zactive/writing ; clear ; ${LL}"
alias zplan="IMPERSONATE_NAME=task ${HOME}/.bashrc impersonate_command %"
alias zdesk="cd ${NULLDIR} ; clear ; ${LL}"
if [[ ${UNAME} == "Windows" ]]; then
alias wsl-link="${RM} \"${HOME}/Desktop\" && ${LN} --relative \"/mnt/c/Users/${USER}/Desktop\" \"${HOME}/\" && ${LN} --relative \"${HOME}/Desktop/_wsl/\"{.Xdefaults,.htoprc.bak,.vimrc} \"${HOME}/\" && ${LN} --relative \"${HOME}/Desktop/_wsl/.bashrc\" \"${HOME}/.bash_aliases\""
alias wsl="${RSYNC_U} root@server.garybgenett.net:{/.g/_data/zactive/.static/{.X*,.bash*,.htop*,.vim*,scripts/updebian},${COMPOSER}} \"${HOME}/Desktop/_wsl/\" && ${SED} -i \"s|([-]0[+]0)|+1800+1920 \# \1|g\" \"${HOME}/Desktop/_wsl/.Xdefaults\" && if [[ -d ${HOME}/Desktop/composer ]] ; then ${RSYNC_U} ${HOME}/Desktop/_wsl/Makefile ${HOME}/Desktop/composer/ ; fi && source \"${HOME}/Desktop/_wsl/.bashrc\""
alias backup="${RSYNC_U} \"${HOME}/Desktop/data\".* root@server.garybgenett.net:/.g/_data/zactive/ ; ${RSYNC_U} \"${HOME}/.history/shell/\"* root@server.garybgenett.net:/.g/_data/zactive/.history/shell/ && ssh root@server.garybgenett.net \"chmod -R 750 /.g/_data/zactive/\$(basename \"${HOME}/Desktop/data\".*)\""
alias server="(urxvt -e bash -c \"${HOME}/.bash_aliases shell me\" &)"
alias xterm="(urxvt &)"
alias xclock="${EDITOR} +/XClock.geometry ${HOME}/.Xdefaults ; (xclock &)"
alias open="/mnt/c/Windows/explorer.exe"
alias zdesk="cd \"${HOME}/Desktop\" ; clear ; ${LL}"
fi
if [[ -n ${CYGWIN} ]] || [[ -n ${CYGWIN_ROOT} ]]; then
alias open="cygstart"
alias zdesk="cd \"${USERPROFILE}/Desktop\" ; clear ; ${LL}"
fi
if [[ "${UNAME}" == "Darwin" ]]; then
#>>> alias open="open"
alias zdesk="cd \"/Users/${USER}/Desktop\" ; clear ; ${LL}"
fi
########################################
alias rsynclook="${GREP} -v -e '^[.<>][fdDLS][ ]' -e '^[[]generator[]]' -e '^[[]sender[]]' -e '^[[]receiver[]]'"
alias dmesgtail="dmesg --kernel --human --decode --ctime --follow"
alias logtail="tail --follow /.runit/log/syslogd"
alias synctail="${GREP} -a '^ERROR[:][ ]' /.g/_data/-track/-sync/_sync.log ; echo ; tail --follow /.g/_data/-track/-sync/_sync.log"
########################################
alias astatus="zstatus ; echo ; zstatus -l 10 gdata/zactive ; echo ; estatus"
alias bshow="_sync backup show"
alias cal="cal --monday --three"
alias clean="_sync clean"
alias clock="clockywock"
alias dict="sdcv"
alias diskio="iostat -cdmtN -p sda,sdb,sdc,sdd 1"
alias doperms="_sync publish perms"
alias dwm-do="xdotool key Super+0 ; xdotool key Super+Shift+grave"
alias emount="_sync upload mount"
alias estatus="_sync upload status"
alias ftp="lftp"
alias jokes="cd data.personal ; ${EDITOR} _jokes.txt ; ${LL} -t"
alias loopfile="dcfldd if=/dev/zero of=/tmp/loopfile bs=1k count=98288"
alias man="PAGER='less' man"
alias mozall="_sync _moz _save"
alias mozall-reset="_sync _moz _clone"
alias mozall-sync="_sync _moz _upload"
alias mozfox="_sync _moz _firefox"
alias mozfox-reset="_sync _moz _firefox _reset"
alias mozfox-view="_sync _moz _firefox _view"
alias mplayer="mplayer -fs"
alias pics="feh -. -g 800x600 -S name"
alias pics-s="feh -F -rz -D5"
alias pics-t="pics --preload --thumbnails --thumb-redraw 0 --index-info ''"
alias pics-x="pics-s /.g/_data/personal/pictures/*/[0-9][0-9][0-9][0-9]"
alias pim-mount="umount -f -l ${PIMDIR} ; mount -t cifs -o ro,soft,username=plastic //10.255.255.254/plastic/_pim ${PIMDIR}"
alias pstree="pstree -clnpuA"
alias publish="_sync publish"
alias quote="cd data.personal ; ${EDITOR} _quotes.txt ; strfile _quotes.txt _quotes.txt.dat ; fortune _quotes.txt ; ${LL} -t"
alias remind="remind -v -uplastic"
alias schedule="remind -v -uplastic -g -m -b1 -cc+2 -w90 ${HOME}/.reminders"
alias sheep="electricsheep --debug 1 --mplayer 1 --server d2v6.sheepserver.net"
alias smount="_sync mount"
alias tasker="prompt -x +task"
alias torrent="rtorrent -n -d ./ -s ./.torrent"
alias trust="_sync archive"
alias vlc-help="${VLC} --help --full-help --longhelp --advanced 2>&1 | ${MORE}"
alias vlc-play="${VLC} ${HOME}/setup/_misc/playlist.m3u"
alias web="w3m https://www.google.com"
alias workspace="_sync workspace"
alias wpa="ip-setup wpa"
alias zshow="_sync zfs show"
alias zstatus="mount-zfs -! -?"
if [[ "${UNAME}" == "Darwin" ]]; then
alias trust="/_install/_mac_osx.txt -r ; /_install/_mac_osx.txt -x ; /_install/_mac_osx.txt -s"
alias workspace="/_install/_mac_osx.txt -w"
fi
################################################################################
# functions
################################################################################
function adb-run {
(cd /.g/_data/_builds/_android && ADB_TRACE=1 ./_adb.sh ${@})
}
########################################
function adb-backup {
adb backup -all -apk -obb -noshared -nosystem -f ${@}
}
########################################
function adb-vpn {
adb forward tcp:8080 tcp:8080 ${@}
adb forward --list
}
########################################
function burn {
if [[ ${1} == -l ]]; then
shift
cdrecord -v dev=ATAPI -scanbus "${@}"
elif [[ ${1} == -i ]]; then
shift
cdrecord -v dev=ATAPI -data "${@}"
elif [[ ${1} == -e ]]; then
shift
cdrecord -v dev=ATAPI -eject "${@}"
elif [[ ${1} == -a ]]; then
shift
cdparanoia -vwB "${@}"
fi
}
########################################
function calendar {
cd ${PIMDIR}
prompt -x ${FUNCNAME}
sudo -H -u \#1000 wyrd \
calendar.rem \
"${@}"
prompt
cd - >/dev/null
return 0
}
########################################
function contacts {
declare CONTACTS="contacts"
if [[ ${1} == -b ]]; then
shift
CONTACTS="contacts-business"
elif [[ ${1} == -k ]]; then
shift
CONTACTS="contacts-keep"
elif [[ ${1} == -l ]]; then
shift
CONTACTS="contacts-ldap"
elif [[ ${1} == -p ]]; then
shift
CONTACTS="contacts-pathfinder"
elif [[ ${1} == -z ]]; then
shift
CONTACTS="contacts-zoho"
perl -e '
use strict;
use warnings;
use JSON::XS;
open(JSON, "<", "./zoho-export.leads.json") || die();
open(ADB, ">", "./contacts-zoho.adb") || die();
my $contacts = do { local $/; <JSON> };
$contacts = decode_json(${contacts});
foreach my $key (sort(keys(%{$contacts}))) {
my $item = $contacts->{$key};
print ADB "[0]\n";
print ADB "name=" . $item->{"Company"} . " :: " . $item->{"First Name"} . "\n";
print ADB "email=" . ($item->{"Email"} || "") . "\n";
print ADB "info=" . ${key} . "\n";
print ADB "mobile=" . ($item->{"Mobile"} || "") . "\n";
print ADB "workphone=" . ($item->{"Phone"} || "") . "\n";
print ADB "address=" . ($item->{"Street"} || "") . "\n";
print ADB "city=" . ($item->{"City"} || "") . "\n";
print ADB "state=" . ($item->{"State"} || "") . "\n";
print ADB "zip=" . ($item->{"Zip Code"} || "") . "\n";
print ADB "country=USA\n";
};
close(JSON) || die();
close(ADB) || die();
' -- "${@}" || return 1
elif [[ ${1} == -c ]]; then
shift
declare EXP_DIR="contacts.export"
${RM} ./${EXP_DIR}/*
declare FILE
for FILE in *.adb; do
sudo -H -u \#1000 abook \
--convert \
--infile ./${FILE} \
--informat abook \
--outfile ./${EXP_DIR}/${FILE/%\.adb}.ldif \
--outformat ldif
${SED} -i \
-e "s/^cn[:][ ](([^ ]+)[ ]?(.*))$/cn: \1\ngivenName: \2\nsn: \3/g" \
-e "s/^xmozillaanyphone[:]/telephoneNumber:/g" \
./${EXP_DIR}/${FILE/%\.adb}.ldif
sudo -H -u \#1000 abook \
--convert \
--infile ./${FILE} \
--informat abook \
--outfile ./${EXP_DIR}/${FILE/%\.adb}.vcf \
--outformat vcard
done
sudo -H -u \#1000 dos2unix ./${EXP_DIR}/*.{ldif,vcf}
for FILE in ldif vcf; do
cat $(${LS} ./${EXP_DIR}/*.${FILE} | ${GREP} -v "[-]keep") >./${EXP_DIR}.${FILE}
${SED} -i \
-e "/^version[:][ ][0-9]+$/d" \
./${EXP_DIR}.${FILE}
done
chmod -R 750 ./${EXP_DIR}*
return 0
fi
cd ${PIMDIR}
prompt -x ${FUNCNAME}
sudo -H -u \#1000 abook \
--config ${HOME}/.abookrc \
--datafile ./${CONTACTS}.adb \
"${@}"
${FUNCNAME} -c
chmod 750 ./${CONTACTS}.adb
prompt
cd - >/dev/null
return 0
}
########################################
function date-string {
date +%Y%m%d-%H%M%S%z
return 0
}
########################################
function dd {
declare SRC="$((${#}-1))" ; SRC="${!SRC}"
declare DST="${#}" ; DST="${!DST}"
declare MAP="/tmp/.${FUNCNAME}-$(basename ${SRC})-$(basename ${DST}).mapfile"
if [[ ${1} == --rescue ]]; then
shift
echo -en "\n"
${LL} ${MAP}
echo -en "\n"
ddrescue --force --idirect --odirect "${@}" ${MAP}
elif [[ ${1} == --dd ]]; then
shift
dd_rescue --alwayswrite "${@}"
else
dcfldd conv=noerror,notrunc "${@}"
fi
return 0
}
########################################
function edit {
declare DIFF="diff"
declare EDIT="${EDITOR}"
declare FILES
declare FILE
if [[ ${1} == -c ]]; then
shift
EDIT="cat"
fi
if [[ ${1} == -d ]] ||
[[ ${1} == -v ]]; then
[[ ${1} == -v ]] && DIFF="vdiff"
shift
for FILE in "${@}"; do
if [[ -d ${FILE} ]] ||
[[ -f ${FILE} ]]; then
FILE="$(readlink -f ${FILE} 2>/dev/null)"
else
FILE="$(which ${FILE} 2>/dev/null)"
fi
echo -en "\n----------[ ${FILE} ]----------\n"
${DIFF} -r ${FILE/zactive/zbackup} ${FILE}
done
elif [[ ${1} == -g ]]; then
shift
${GREP} -r "${@}" \
/.g/_data/zactive/.setup \
/.g/_data/zactive/.static |
${GREP} -v "[+.]git" |
${GREP} "${@}"
elif [[ ${1} == -r ]]; then
shift
env ${EDIT} $(
bash -c "source ${HOME}/.bashrc ; ${FUNCNAME} -g ${@}" |
${GREP} -v "^Binary" |
cut -d: -f1 |
sort |
uniq
)
elif [[ ${1} == -e ]]; then
shift
for FILE in "${@}"; do
set 2>&1 | ${MORE} +/^${FILE}
done
else
for FILE in "${@}"; do
FILES="${FILES} $(which ${FILE} 2>/dev/null)"
done
${EDIT} ${FILES}
fi
return 0
}
########################################
function email {
declare TMPDIR="${HOME}/Desktop"
declare MUTTRC="${HOME}/.muttrc"
declare MUTT_X="${NULLDIR}/_mutt_mail"
if [[ ${1} == -a ]]; then
shift
MUTTRC="${MUTTRC}.all"
fi
if [[ ${1} == -p ]]; then
shift
MUTTRC="${HOME}/.procmail.mutt"
fi
sudo -H -u \#1000 \
${MKDIR} ${TMPDIR}
cd ${TMPDIR}
prompt -x ${FUNCNAME}
if [[ ${1} == -x ]]; then
shift
EMAIL_MAIL="${EMAIL_MAIL:-root@garybgenett.net}"
EMAIL_NAME="${EMAIL_NAME:-GaryBGenett.net Automation}"
declare LINE
declare VAR
declare VAL
echo "source ${MUTTRC}" >${MUTT_X}
${SED} -n "/^alternates.+${EMAIL_MAIL}$/,/^$/p" ${MUTTRC} |
${SED} -n "s/^<enter-command>(.+)<return>.+$/\1/gp" |
while read -r LINE; do
VAR="$(echo "${LINE}" | ${SED} -n "s/^.+[$](my[_].+)$/\1/gp")"
if [[ -n ${VAR} ]]; then
VAL="$(${SED} -n "s/^set[ ]${VAR}.+[=](.+)$/\1/gp" ${MUTTRC})"
echo "${LINE}" | ${SED} "s|[$]my[_].+$|${VAL}|g"
else
echo "${LINE}"
fi
done >>${MUTT_X}
if [[ -n ${EMAIL_MAIL} ]]; then echo "set from = '${EMAIL_MAIL}'"; fi >>${MUTT_X}
if [[ -n ${EMAIL_NAME} ]]; then echo "set realname = '${EMAIL_NAME}'"; fi >>${MUTT_X}
echo "set copy = no" >>${MUTT_X}
${REALTIME} \
sudo -H -u \#1000 \
TMPDIR="${TMPDIR}" \
mutt \
-d 2 \
-nxF ${MUTT_X} \
"${@}"
cat ${HOME}/.muttdebug0
${RM} ${HOME}/.muttdebug0
elif [[ ${1} == -c ]]; then
if [[ -d "${MAILDIR}" ]]; then
declare CRUFT="$(cd ${MAILDIR}; find $(find . -type d | ${GREP} "[/]tmp$") ! -empty | sort)"
declare EMPTY="$(cd ${MAILDIR}; find . -type f -empty | ${GREP} -v "[./]lock$" | sort)"
if [[ -n ${CRUFT} ]] || [[ -n ${EMPTY} ]]; then
echo -en "[CRUFT]\n${CRUFT}\n"
echo -en "[EMPTY]\n${EMPTY}\n"
cd - >/dev/null
return 1
fi
${RM} "${MAILDIR}/-mutt"
else
${LL} "${MAILDIR}"
fi
else
${MKDIR} "${MAILDIR}/-mutt"
chown -R plastic:plastic "${MAILDIR}/-mutt"
${REALTIME} \
sudo -H -u \#1000 \
MAILDIR="${MAILDIR}" \
TMPDIR="${TMPDIR}" \
EDITOR="${VI} +/^$" \
DISPLAY=":0" \
mutt \
-nF ${MUTTRC} \
"${@}"
fi
prompt
cd - >/dev/null
return 0
}
########################################
function email-copy {
declare TMPFILE="${NULLDIR}/_mutt_copy"
declare SRC="${1}"
declare DST="${2}"
if [[ -d ${SRC} ]] && [[ -d ${DST} ]]; then
echo -en "set mbox_type = maildir\n" >${TMPFILE}
echo -en "folder-hook . \"push " >>${TMPFILE}
echo -en "<tag-pattern>~A<return>" >>${TMPFILE}
echo -en "<tag-prefix><copy-message><kill-line>${DST}<return>y" >>${TMPFILE}
echo -en "<quit>y" >>${TMPFILE}
echo -en "\"\n" >>${TMPFILE}
sudo -H -u \#1000 mutt \
-nF ${TMPFILE} \
-zRf ${SRC}
${RM} ${TMPFILE}
fi
return 0
}
########################################
function enc-fs {
declare DST="${#}"; DST="$(realpath ${!DST})"
declare OUT=
if [[ ! -f ${ENCFS_FILE} ]]; then
echo -en "${FUNCNAME}: "
read -s OUT
echo -en "\n"
else
OUT="$(gpg --decrypt ${ENCFS_FILE} 2>/dev/null)"
fi
mount-robust -u ${DST}
echo -en "${FUNCNAME}: mounting..."