-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliases
1327 lines (1295 loc) · 48.9 KB
/
aliases
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
# vim: se ft=sh:
UNAME=$(uname)
: "${TMPDIR:=/tmp}"
if [ "$OSTYPE" = "cygwin" ]; then
alias sudo="cygstart --action=runas"
fi
# Change directory
alias .....='cd ../../../..'
alias ....='cd ../../..'
alias ...='cd ../..'
alias ..='cd ..'
alias cdd='cd $PWD'
alias cdv='cd $(prl $dirstack | fzf)'
source ~/.dotfiles/z/z.sh
# AOSP
alias aosp='cd "$AOSP_HOME" && source build/envsetup.sh && export OUT_DIR_COMMON_BASE="$AOSP_HOME/out.$MYHOSTNAME"'
# alias adbk='adb shell input keyboard text \"\"'
# alias adf=adbfs
adf() {
[[ -z $ANDROID_SERIAL ]] && {
print -u "Please set ANDROID_SERIAL"
return 1
}
adbfs_mnt=/ADBFS/$ANDROID_SERIAL
mkdir -p $adbfs_mnt
adb shell id
sudo -E adbfs -o allow_other -o auto_unmount $adbfs_mnt
${EDITOR:-nvim} $adbfs_mnt
}
alias af=adbfs
alias adkl=adbk
alias adke='adb shell input keyevent'
alias adbke='adb shell input keyevent'
alias als='noglob adb shell ls -alZ'
alias aff='noglob adb shell find /sys/class/ -xdev -context u:object_r:sysfs_leds:s0 -printf '\''"%M\t%Z\t%u:%g\t%p\t%l\n"'\'''
alias adk=adbk
adbk() { timeout 10 adb shell input keyboard text "${(q)*}$'\n'" }
# adbk() { adb shell input keyboard text "${(q)*}" && adb shell input keyevent KEYCODE_ENTER ; }
alias adkp="adb shell input keyboard text \\\"\$(cat | tr -c '[\\r\\n[:space:][:graph:]]' '_')\\\""
# alias adl='adb_real_serial=$(adb shell getprop ro.serialno) && logcat=~/.logs/adb/$(nn)-$adb_real_serial.log.gz ; typeset -p logcat ; adb logcat | ( gzip | tee $logcat ) | lnav -q'
# j
alias adl='adb_real_serial=$(adb shell getprop ro.serialno) && logcat=~/.logs/adb/$(nn)-$adb_real_serial.log; typeset -p logcat ; ( while :; do adb logcat ; sleep 1.1 ; done ) |& tee -a $logcat | lnav -q'
alias adR='adb reboot ; sleep 2 ; adb wait-for-device && adb root && adb shell getprop ro.build.type'
alias adld='adb_real_serial=$(adb shell getprop ro.serialno) && logcat=(~/.logs/adb/*-$adb_real_serial*(om[1])) && typeset -p logcat && nvim -c "se ft=strace" $logcat'
alias ngrs=ngr_setting
alias nss=ngr_setting
alias adll='noglob adb logcat -d'
alias adldl='noglob adb logcat -d | vim -c "se ft=strace" -'
# alias add='adb devices -l | head -n-1 | tail -n+2 | cat -ns'
alias add='adb devices -l'
alias acu='source ~/.android/current_serial ; adi'
alias adsp='adb shell setprop'
alias adgp='adb shell getprop | sort'
alias adgpp='adb shell getprop'
alias ado='adb_real_serial=$(adb shell getprop ro.serialno) && typeset -p adb_real_serial ; echo $adb_real_serial ; tmux rename-window $adb_real_serial-RUN'
alias adro='adb_real_serial=$(adb shell getprop ro.serialno) && typeset -p adb_real_serial ; echo $adb_real_serial ; tmux rename-window $adb_real_serial-RUN'
alias adi="adb shell <<< 'getprop ro.serialno ; getprop ro.product.model ; getprop ro.build.type ; getprop ro.build.version.incremental ; getprop ro.build.date; echo tcp_port=\$(getprop service.adb.tcp.port) ; id ; uptime -s ; uptime -p' ; "
adb_all() {
setopt nomonitor
target_devices=()
if [[ $1 = -t || $1 = -s ]]; then
target=$1
while :; do
shift
target_devices+=($1)
shift
[[ $1 = $target ]] || break
done
fi
[[ $1 = -t || $1 = -s ]] && { echo "Cannot use -t and -s at the same time."; return; }
if [[ $target = -s ]]; then
devices=( $( adb devices 2>$null | tail -n+2 | cut -f 1 ) )
cmd=$*
else
if [[ $1 = adb ]]; then
shift
cmd=$*
else
echo "Cannot target transport id for non-adb commands."
return 1
fi
target="-t"
devices=( $( adb devices -l | tail -n+2 | awk -F: '{print $(NF)}' ) )
fi
# typeset -p target_devices devices
tmp_files=()
tmp_dir=~/.logs/adb/$(date '+%F__%H.%M.%S')-${cmd//(#m)[[:space:]\/]/_}
mkdir -p $tmp_dir
for device in $devices; do
# typeset -p device
real_serial=$( adb $target $device shell getprop ro.serialno )
[[ -z $real_serial ]] && {
echo "$device:\tFailed to get serial for $device ($target)"
continue
}
# TODO: Find something more "unique": MAC addresses, IMEI, etc.
tmp_file=$tmp_dir/$real_serial-$device
[[ $#target_devices -eq 0 ]] || (( $target_devices[(I)$device] )) && {
tmp_files+=($tmp_file)
(
{
if [[ $target = "-s" ]]; then
ANDROID_SERIAL=$device $=cmd
else
adb -t $device $=cmd
fi
} |& tee $tmp_file | sed "s|^|$real_serial ($device):\t|" ) &
}
done
wait
for target_device in $target_devices; do
(( $devices[(I)$target_device] )) ||
echo "WARNING: Target device $target $target_device not found."
done
# typeset -p tmp_files tmp_dir
typeset -p tmp_dir
echo nvim -d $tmp_dir/*
}
adb_device_n_disconnect() {
adb_device_n &&
adb disconnect $ANDROID_SERIAL
adb_device_n
}
adb_device_n() {
echo $( adb shell <<< ' getprop ro.product.model ; getprop ro.serialno ; getprop service.adb.tcp.port ; cmd wifi status | sed -nE "/Wifi is connected to \"(.*)\"$/s||\1|p" ' )
typeset -p ANDROID_SERIAL
adb reconnect offline ; sleep 0.1
serials=( $( adb devices 2>/dev/null | tail -n+2 | cut -f 1 ) )
(( #serials == 0 )) && { echo "No devices found."; return ; }
integer n=$1
(( n == 0 )) && [[ ${#serials} == 1 ]] && n=1
(( n == 0 )) && {
{ for ((i = 1; i <= $#serials; i++)); do
setopt nomonitor
(
export ANDROID_SERIAL=${serials[i]}
# print -u2 "Querying $ANDROID_SERIAL"
real_serial=$( timeout 1 adb shell getprop ro.serialno 2> $null )
[[ -z $real_serial ]] && {
print -u2 "$ANDROID_SERIAL: Failed to acquire real serial for $ANDROID_SERIAL"
continue
}
user=$( adb shell id -un )
model=$( adb shell getprop ro.product.model 2> $null )
date=$( date '+%F %T' --date=@$( adb shell getprop ro.build.date.utc ) )
version=$( for prop in ro.build.version.release ro.build.version.incremental ro.vndk.version ro.kernel.version ro.build.version.codename ro.build.version.security_patch ; do adb shell getprop $prop; done | tr '\n' '\t' )
# ssids=$( echo $( adb shell cmd wifi list-scan-results | vd -f fixed --delimiter=, -b -o - 2>$null | xsv select SSID 2>$null | head -8 ) )
ssids=""
print "$i\t$ANDROID_SERIAL\t$real_serial\t($user)\t$model\t$date\t$version\t($ssids)"
)&
done
wait
} | sort -n | column -ts $'\t'
echo -n "Enter device number: " ; read n ;
}
(( n < 1 )) || (( n >= #serials )) && { print -u2 "Invalid device number"; return; }
export ANDROID_SERIAL=${serials[$n]} && adi
export adb_real_serial=$( adb shell getprop ro.serialno 2>$null )
typeset -p ANDROID_SERIAL adb_real_serial > ~/.android/current_serial
adb forward --remove tcp:8022 2> $null
adb forward tcp:8022 tcp:8022 > $null
termux_ssh=(ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=off -o IdentitiesOnly=yes -o IdentityFile=$HOME/.ssh/keys/thc_termux_user -p 8022 $lo)
has adbfs && {
adbfs_path=/ADBFS/$adb_real_serial
$sudo umount -R $adbfs_path &> $null || true
mountpoint -q $adbfs_path || {
sudo -E mkdir -p $adbfs_path
sudo -E adbfs -o allow_other -o auto_unmount $adbfs_path
}
echo ls -al $adbfs_path
alias cda="cd $adbfs_path"
}
# zsh_prepend \$termux_ssh >$null
#
}
alias adn=adb_device_n
alias adN=adb_device_n_disconnect
alias adnn=adb_device_n_disconnect
alias an=adb_device_n
alias ad1="adb_device_n 1"
alias ad2="adb_device_n 2"
alias ads='adb shell'
alias admm='adb shell monkey -p $pkg 1'
alias adr='adb shell run-as $pkg'
alias ada='adb shell am start'
alias adss='adb shell am start -S'
alias adp='adb shell dumpsys'
alias adpp='adb shell dumpsys package'
alias addd='adb shell dumpsys'
alias aps='adb shell ps -Awf -Z -T'
alias adps'adb-ps.sh'
alias adu='export ANDROID_SERIAL=$( adb -d get-serialno ) ; adi'
alias adm='export ANDROID_SERIAL=emulator-5554'
ash() {
[ -z "$ANDROID_SERIAL" ] && ANDROID_SERIAL=$(adb get-serialno 2> /dev/null)
[ -z "$ANDROID_SERIAL" ] && ( echo No Android device found...; exit 1 )
type prompt_tag > /dev/null 2>&1 && prompt_tag "[ANDROID_SERIAL=$ANDROID_SERIAL]"
echo $ANDROID_SERIAL: $@
adb shell $@
}
alias a_=ash
a_pidof() { echo $(adb shell ps | grep "$@" | cut -c 9-15 ); }
a_pidof1() { echo $(adb shell ps | grep "$@" | cut -c 9-15 | head -1 ); }
# find
alias f=find
alias fBB='find . \( -type d -exec chmod -c 755 {} \; \) -o \( -type f -exec chmod -c 644 {} \; \)'
alias fBBB='find . \( -type d -exec chmod -c 700 {} \; \) -o \( -type f -exec chmod -c 600 {} \; \)'
alias fBBx='for f in $(find -type f); do file -L $f | grep -q -E ELF\|executable && chmod -c a+x $f; done || true'
alias fdd='f . -type d'
# alias ff='f . -type f'
alias ffn='ff -name'
alias fgr='f . | grep -i --color=auto '
alias lc='locate --ignore-case --existing --regex '
loc() { lc "$*" | grep --ignore-case --color "$*"; }
alias locl=lloc
lloc() { lc "$*" | sed -ne "s|$PWD|.|p" | grep --color "$*" ; }
lloc2() { locate --wholename --regexp="^$PWD"| sed -ne "s,^$PWD,.,p" | grep --color --fixed-strings "$*"; }
loce() { loc \\.$1\$; }
locee () { loc $1\$; }
locE() { loc $1\$; }
loCE() { loc $1\$; }
alias cq=copyq
alias df='\df -h | sort -k 6,6 | sed "/^Filesystem/d"'
# alias df='findmnt -D'
# git
alias g=git
alias gi=git
alias gf='git fetch'
alias gcm='git commit --verbose -m ""'
alias gC='git cherry --verbose'
alias gcn='git clean --dry-run'
alias gca='git commit --verbose --amend'
alias gcop='git checkout --patch'
alias gdf='noglob git diff --ext-diff --ignore-space-change --ignore-blank-lines'
alias gdff='noglob git diff --ext-diff --ignore-space-change --ignore-blank-lines -- .'
alias grp='git reset --patch'
# alias gst='git -c color.ui=always status -sb --show-stash'
alias gst='git submodule ; noglob git status -sb -- '
alias gst.='noglob git status -sb -- ./'
alias gstt='noglob git status -sb -- ./'
alias gs='noglob git status -sb -- ./'
alias gw='git worktree'
alias gw='git worktree'
alias gws='git worktree'
alias gwl='git worktree list'
alias gwsgl='git worktree list'
alias glg='noglob git log -n 10'
# gst() {
# local git_min_version="2.10.0"
# }
gcr() {
set -x
git clone --recursive --jobs=8 --verbose $1 &&
cd ${${1:t}%%.git} &&
$EDITOR .
}
ghssh() {
local dsh2_https_base='https://github.com/dsh2'
local dsh2_ssh_base='[email protected]:dsh2'
for remote in $(git remote); do
remote_url=$(git remote get-url --push $remote)
if [[ $remote_url =~ $dsh2_https_base ]]; then
remote_url_new=${remote_url/$dsh2_https_base/$dsh2_ssh_base}
echo Switching url \"$remote_url\" to \"$remote_url_new\"
git remote set-url $remote --push $remote_url_new
elif [[ $remote_url =~ $dsh2_ssh_base ]]; then
remote_url_new=${remote_url/$dsh2_ssh_base/$dsh2_https_base}
echo Switching url \"$remote_url\" to \"$remote_url_new\"
git remote set-url $remote --push $remote_url_new
else
echo Skipping $remote_url
fi
done
}
alias gcrs='git clone --recursive --jobs=8 --verbose --shallow-submodules --depth 1'
alias gcrss='git clone --recursive --jobs=8 --verbose --shallow-submodules --no-single-branch --shallow-since="1 year ago"'
alias grv='git remote --verbose'
alias gfa='git fetch --all --tags --progress --verbose'
alias gco='git checkout'
alias gcom='git checkout main'
alias gcol='git checkout local'
alias gA='mlocate -eb \\HEAD | while read p; do p=${p:h}; [[ -d $p/objects && -f $p/config ]] && echo $p; done'
alias gk='x0; gitk --date-order --all&'
alias gkk='v +"GV --all"'
alias gss='GIT_MODIFIED_FILES=$(git ls-files --modified) && [ -n $GIT_MODIFIED_FILES ] && $EDITOR $=GIT_MODIFIED_FILES +Gstatus +only'
alias gcp='git cherry-pick -x'
alias gcpa='git cherry-pick --abort'
alias gsl='git stash list -p'
alias gpp='git pull --recurse-submodules --jobs=8 && git submodule update --init --merge --recursive'
alias gppp='git pull --recurse-submodules --jobs=8 && git submodule update --init --merge --recursive && git push --recurse-submodules=on-demand'
alias gpP='git pull --recurse-submodules --jobs=8 && git submodule update --init --merge --recursive && git push --recurse-submodules=on-demand'
alias gaa='git apply --verbose --check --3way'
# TODO: add to fbr
alias gbb='git checkout $(git for-each-ref --format="%(color:red)%(objectname:short)%(color:reset) %(HEAD) (%(color:green)%(committerdate:format:%a %F %T) - %(committerdate:relative)%(color:reset)) %09 %(color:yellow)%(refname:short)%(color:reset) %09 %(contents:subject) (%(color:green)%(authorname)%(color:reset))" --sort=committerdate | fzf --tac --tabstop=17 --preview="git log --color --graph --pretty=format:\"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\" --abbrev-commit -p {1}" | cut -f 1 -d\ )'
alias gb='git branch'
alias gba='noglob git branch -a -vv --list'
alias gcs='git config --show-origin'
alias gra='git rebase --abort'
alias grC='git rebase --continue'
alias gri='git rebase --interactive --autosquash'
alias grh='noglob git reset HEAD^'
alias grH='noglob git reset HEAD@{1}'
alias gsm='git submodule'
alias gsmp='git submodule foreach git pull'
alias gsma='git submodule foreach'
alias gsmA='git submodule foreach ""'
alias gsmcm='git submodule foreach git checkout main'
alias gsmu='git submodule update --init --recursive'
alias gtl='git tag --sort=-taggerdate | head -1'
alias gci='git config --show-origin --get-regexp user.\*; git init && git add . && git commit -m "Initial commit"'
# ls
# alias ls="$LS_COMMAND -Z --almost-all --escape --classify --color=always --time-style='+%F %T'"
alias l='ls -lh'
alias l1='ls -1'
alias lD='l --group-directories-first'
alias lt='l -tr'
alias lts='l -rS'
alias ltsh='l -rS -h'
alias ltr='ls -al **/*(.om) '
alias ltrD='ls -dal **/*(/om) '
alias lsd='l -d'
alias lS='ls -ahlSsr'
alias fre='free -hwt'
alias tt=set_terminal_title
alias vb=vboxmanage
alias stcp='host=$( echo 127.0.0.1 ) ; iface=$( echo any ) ; filter=$( echo port not 22 ) ; pcap=~/.pcaps/$(nn)-$host.pcap ; ssh $host sudo stdbuf -o0 tcpdump -pUnni $iface $filter -w - | tee $pcap | tcpdump -pUnnr - '
alias tcp='iface=$( echo any ) ; filter=$( echo icmp ) ; pcap=~/.pcaps/$(nn).pcap ; sudo tcpdump -pUnni $iface $filter -w - | tee $pcap | tcpdump -pUnnr - '
# alias tcp='sudo tcpdump -pUnni any icmp'
alias tcpd='sudo tcpdump -pUnni any icmp'
alias tcpa='adb shell -t tcpdump -pUnni any icmp'
alias tcpD='tcpdump -D | cut -d. -f2- | sort -n'
alias tcpP='sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump'
# alias tsk='pcap=~/.pcaps/tcpdump-$(nn).pcap; tshark --capture-comment "" -qwnlpFpcap -qwn -w - -i any | tee $pcap | tshark -t a --color -r -'
alias tsk='interface= any; filter="not port 22"; comment=""; pcap=~/.pcaps/$(nn)-$interface.pcap; tshark -QwnlpFpcap -w - --capture-comment "$comment" -i $interface $filter | tee $pcap | tshark --color -T tabs -lt a -r - '
alias tskl='interface=any; filter="not port 22"; comment=""; pcap=~/.pcaps/$(nn)-$interface.pcap; touch $pcap.txt; echo $pcap.txt; ( setopt nomonitor ; tshark -QwnlpFpcap -w $pcap --capture-comment "$comment" -i $interface $filter ) & tmux split -p 99 "less +F $pcap.txt"; (trap "kill $!" INT EXIT; script -qfc "tshark -o protocols.display_byte_fields_with_spaces:\ false -o gui.column.format:\ \$columns -T tabs -lt a -r <(tail --pid=$! -c+0 -s0.1 -qF $pcap 2> /dev/null) --color" $pcap.txt ) > /dev/null'
alias tmH='tmux rename-session $(hostname)'
alias tskO='export columns='\''"Time", "%t", "No.", "%m", "Source", "%s", "Comment", "%Cus:frame.comment :0:R", "Destination", "%d", "Info", "%i", "Expert Info", "%Cus:_ws.expert.message:0:R", "f.proto", "%Cus:frame.protocols:0:R", "data.data", "%Cus:data.data:0:L"'\'''
# alias tsk='pcap=~/.pcaps/$(nn).pcap; touch $pcap && tshark -i any --capture-comment "" -qwnlpfpcap -w $pcap& tail -c0 -f $pcap | tshark --color -r - -c ssl '
alias tsc='capinfos -m -T ~/.pcaps/*.pcap | column -nts,'
alias tskc='capinfos -m -T ~/.pcaps/*.pcap | column -nts,'
# alias tsa='mergecap ~/.pcaps/*.pcap(.rm-1) -w - | tshark -r - -qz io,phs'
alias tsa='mergecap ~/.pcaps/*.pcap(.om[1]) -w - | tshark -r - -qz io,phs'
alias wsd='wireshark -r ~/.pcaps/*(.om[1])&'
alias wsa='wireshark -r $pcap&'
alias wgq=wg-quick
alias nmap='nmap -oA ~/.logs/nmap/log-$(nn) -p- '
alias nmr='nmap --resume ~/.logs/nmap/*.gnmap(.om[1])'
alias nmz='nmapfe ~/.logs/nmap/*.xml(.om[1])'
alias ln='ln -rsv'
alias lv='lnav -q'
alias lnn='lnav -q'
alias lna='lnav -q'
alias lvv='lnav -q'
alias lqq='lnav -q'
alias r=ranger
alias ra=ranger
alias ran=ranger
alias rD='ranger $(xdg-user-dir DOWNLOAD)'
alias zl='fc -rlEDt "%a %F %T" 1 gg'
alias za='echo Sourcing ~/.aliases; time source ~/.aliases'
alias zs=zstyle
alias zz='echo exec $SHELL; exec $SHELL'
alias zzz='echo Sourcing ~/.zshrc; time source ~/.zshrc'
alias msf='./msfconsole --real-readline --quiet -r $HOME/.dotfiles/msfc.rc'
alias ms=msf
alias mkd='mkdir -p'
mkt() { TMP=tmp-$(nn); [[ -n $* ]] && TMP+=-${(q)*}; mkd $TMP; cd $TMP; }
mcd() {
DIR=$*
if [[ -z $DIR ]]; then
echo usage: mcd NEWDIR
return
fi
mkd $DIR && cd $DIR
}
alias mcdb='mcd BUILD-$(nn)'
alias mkp=mkd
alias goo=googler
alias wh='whence -sv'
alias whh=whence
alias prr=print
alias prl='print -rl -- '
alias prn='print -rn -- '
alias prv=printenv
alias j='jobs -l'
alias jk='kill ${${(v)jobstates##*:*:}%=*}'
alias jkk='kill -9 ${${(v)jobstates##*:*:}%=*}'
alias jk9=jkk
alias d='diff -u'
alias vf=vimdiff
alias vimd=vimdiff
alias wanip='dig +short myip.opendns.com ANY @resolver1.opendns.com'
alias wanipx='dig -x $(wanip)'
alias wanip2='curl -s https://checkip.amazonaws.com'
alias wanip2x='dig -x $(wanip2)'
alias wanip3='dig TXT +short o-o.myaddr.l.google.com @ns1.google.com'
alias lanip='for if in $(\ls -1 /sys/class/net); do if [ $if != "lo" -a $(cat /sys/class/net/$if/operstate) = "up" ]; then echo $if:\\t$(ifdata -pa $if); fi; done'
alias PV=print_variables
alias PVV=print_variables
alias pvv=print_variables
envof() { sed 's/\x0/\n/g' /proc/${1}/environ; }
alias va=vagrant
# alias va=variety
alias doc=docker
alias doo=docker
alias docc=docker-compose
alias dock=docker
alias wgk='{ wg genkey 1>&2 | wg pubkey | sed "s:^:PublicKey = :" 1>&3 } 2>&1 3>&2| sed "s:^:PrivateKey = :" 3>&-'
# Vim aliases
# alias v=vim
alias v=$EDITOR
gv() { gvim "$*"; raiseX; }
# alias vl='(cd ~/.tmux-log/; v *(.om[1]))'
viminfo() { $EDITOR -R -c "Info $1 $2" -c "bdelete 1" -c "setlocal nomodifiable" ; }
vimman() { $EDITOR -R -c "Man $1 $2" -c "bdelete 1" -c "setlocal nomodifiable" -c "map Q :cq<cr>" -c "set cursorline" "+silent! /example"; }
# vimman() { vimx -R -c "Man $1 $2" -c "bdelete 1" -c "setlocal nomodifiable" -c "map Q :cq<cr>" -c "set cursorline" "+silent! /example"; }
alias nv=nvim
alias m=vimman
alias mm="vimman \$(man -k . | fzf | sed -e 's,\(.*\) (\([^)]*\).*-.*,\1.\2,')"
alias q=qemu
alias qq=qemu-system-x86_64
alias qqi=qemu-system-i386
# alias qm='sudo qmicli -p -d /dev/cdc-wdm0'
alias qe=qemu-system-sparc64
alias qmi=qemu-img
alias qi=qemu-img
RUN() {
# TODO
# -Add option to run through watch to show diffs in output
# -Measure runtime
# -Log output in tmux-log or similar
# -Press any key for manual run
# o:=output_dir -output-dir:=output_dir \
# t:=meassure_runtime -meassure-runtime:=meassure_runtime \
local -a watch_objs
if [ $# = 0 ] || ! zparseopts -D \
w+:=watch_objs -watch+:=watch_objs \
1=watch_run_objs \
x=clear_screen c=clear_screen -clear=clear_screen \
d=diff_output -diff-output=diff_output \
s=skip_first_run -skip-first-run=skip_first_run \
t=print_time -time=print_time \
v=verbose -verbose=verbose \
; then
print "usage: RUN [--skip-first-run] [--watch_file file] executable [args]"
return 1
fi
watch_objs=(${watch_objs:gs:--watch:::gs:-w::}) # HELP: This cannot be - by no means - zsh-idiomatics
[[ $#watch_objs = 0 || -n $watch_run_objs ]] && watch_objs+=$1
[[ -f $watch_objs[1] ]] || watch_objs[1]=$(whence $watch_objs[1])
run_obj=$*
[ -z $run_obj ] && { echo "Nothing to run."; return; }
[ $#watch_objs = 0 ] && { echo "Nothing to watch."; return; }
# TODO: Resolve target executable
# [ ! -e $WATCH ] && WATCH=$(whence $WATCH)
local tmp_out=$(mktemp -t RUN_XXXXXX)
while :; do
if [[ -z $skip_first_run ]]; then
[[ -z $clear_screen ]] || clear -x
[[ -z $verbose ]] || print -l "Watching: $watch_objs" "Running: $run_obj" "Output: $tmp_out"
[[ -z $print_time ]] || print "Start: $(n)"
print -P $LINE_SEPARATOR
$=run_obj |& tee $tmp_out
err=$pipestatus[1]
print -P $LINE_SEPARATOR
(( err )) && err "err = $err"
[[ -z $print_time ]] || print "Stop: $(n) err = $err"
fi
unset skip_first_run
inotifywait -qqe attrib,move_self,modify $=watch_objs || { echo "inotifywait failed!" ; return ; }
# TODO: check if run failed. Add options for sleep, ignore, abort, etc.
sleep 0.1
done
}
# Miscellaneous
# alias a=aws
alias a=adb
alias ad=adb
alias afs=adbfs
alias al='aws ec2'
alias ae='aws ec2'
alias e2='aws ec2'
alias ae2='aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text --filter Name=ip-address,Values='
alias aeA='aws ec2 describe-instances --filter Name=instance-state-name,Values=running --query "Reservations[].Instances[].InstanceId" --output text'
alias aI='( for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output text); do aws --region $region ec2 describe-instances | jq -r ".Reservations[].Instances[] | [.LaunchTime, .InstanceId, .ImageId, .InstanceType, .PublicIpAddress, .State.Name, [[.Tags[]?] | map(.Key + \"=\" + .Value) | .[] ] ] | flatten | @csv" | sed "s:^:$region,:"& done; wait ) | sort -k 2,1 | column -tns, | tr \" \ '
alias aeAT="aws ec2 terminate-instances --instance-ids \$(aeA) --output table"
alias aed="aws ec2 describe-instances --instance-ids"
# alias ac='aws cloudformation'
# alias ac='aws cognito-idp'
alias ax=autorandr
alias xx=xrandr
alias TCPTRACEOPTS_minimal='export TCPTRACEOPTS="--noshowdupack3 --noshowsacks --noshowrexmit --noshowoutorder"'
alias TCPTRACEOPTS_normal='export TCPTRACEOPTS='
alias Xreseed="dd if=/dev/urandom count=1 2> /dev/null | md5sum | sed -e 's,^\([! ]*\).*$,add :0 . \1,' | tee /dev/stderr | xauth"
alias le=$PAGER
alias el=$PAGER
alias psp='pstree -laps'
alias psme='pstree -ahups $$'
alias p_s='port search --line'
alias tm=tmux
alias tmda='tmux detach-client -a'
alias tma='if tmux has-session; then tmux attach; else tmux new-session -s ROOT -n top ; fi'
alias tmn='tmux new-session -t $(tmux list-sessions -F "#S"|head -1)'
# alias tmm='TAG_NAME=$(herbstclient attr tags.focus.name 2> /dev/null || i3-msg -t get_workspaces | jq -r ".[] | select(.focused == true) | .name" 2> /dev/null ) && if tmux has-session -t $TAG_NAME >/dev/null; then tmux attach-session -t $TAG_NAME; else tmux new-session -s $TAG_NAME -n $TAG_NAME; fi'
tmm() {
TAG_NAME=$(has herbstclient && herbstclient attr tags.focus.name 2> /dev/null || i3-msg -t get_workspaces | jq -r ".[] | select(.focused == true) | .name" 2> /dev/null)
TAG_NAME=$(echo $TAG_NAME | cut -d : -f 2-)
if tmux has-session -t $TAG_NAME >/dev/null; then
tmux attach-session -t $TAG_NAME
else tmux new-session -s $TAG_NAME
fi
}
alias tmk='for s in $(tmux list-sessions -F "#{session_name}"); do if [[ $s =~ "-[0-9]*$" ]]; then echo Killing session "$s"; tmux kill-session -t $s; fi; done'
alias tms='tmux source-file ~/.tmux.conf'
alias tmss='tcmd="tmux set -g status-style fg=colour$((RANDOM%255)),bg=colour$((RANDOM%255)); tmux set -g window-status-style fg=colour$((RANDOM%255))"; echo $tcmd; eval $tcmd'
alias tmo='for scope in server global window; do tmux show -${scope:0:1} | sed "s:^:$scope\: :"; done'
alias tmO='old_clients=$(tmux list-clients -F "#{client_activity},#{client_tty}" | sort | tail -n+2 | cut -d, -f2); if [ -n $old_clients ]; then for old_client in $old_clients; do tmux detach-client -t $old_client; done; else echo "No other tmux clients."; fi'
alias vp='vim -c "nmap Q :q!<cr>" -c "setlocal nomodifiable" -'
alias vpcsv='vim -c "let b:csv_headerline = 0" -c "set filetype=csv" -c "%CSVArrangeColumn!" -c "nmap Q :q!<cr>" -c "set nomodifiable" -'
alias vpp=vpcsv
alias tag=prompt_tag
alias agg='ag --depth=-1'
alias rgg='time rg --stats --no-search-zip -g '\''*.c'\'' '
# gw() { grep --color -Iwri -- "$@" *; }
alias grep='grep --color'
# alias pg='ping gdns |& lnav -qt'
alias pg='pgrep -ax'
alias acs='apt-cache search'
alias r22='rabin2 -gx'
alias pl='patool list'
alias pc='psql -c ""'
alias pC="psql -c ''"
alias px='patool extract'
alias pd='patool diff'
alias o=xdg-open
# alias q='qiv -uBfta '
alias bw='binwalk -veBAEJ -cf binwalk-log.csv '
alias xc='xclip -selection clipboard -in'
alias wp='echo -n $(powershell.exe Get-Clipboard)'
alias xcc='tmux show-buffer | xc'
alias XS='xset -b -c r rate 200 140 dpms 0 0 3600 s off; setxkbmap -layout us,de -option grp:alt_caps_toggle; xmodmap -e "keycode 94 = asciitilde asciitilde asciitilde asciitilde"'
alias M='make -j $(nproc)'
alias makev='make SHELL="PS4=__[MAKE]__\ \$\$SHELL -x"'
alias ndd=ndk-build
alias tss='typeset -p'
alias rh=rehash
alias ipp='ipython3 -i -- '
alias iz=ipython3
alias pz=python
alias p2=python2.7
alias ip='ip -c -o -d -s'
alias ip4='ip -4 -c -o -d -s'
alias 4ip='ip -4 -c -o -d -s'
alias ip6='ip -6 -c -o -d -s'
alias ip44='ip -6 -c -o -d -s'
alias 6ip='ip -6 -c -o -d -s'
alias ipr='\ip -c -o -d -s route show table all'
alias ipt='sudo iptables -nv'
alias ipta='sudo iptables -nv'
alias iptn='sudo iptables -nv -t nat'
alias iptL='sudo iptables -nvv --line-numbers -L'
alias iptl='sudo iptables -nvv --line-numbers -L'
alias ipts='for ipt in iptables ip6tables; do for table in security raw nat mangle filter ; do sudo $ipt -S -t $table | sed "s:^:-t $table :" ; done ; done'
alias ipl='\ip -c -o -d -s link show | column -t'
alias ipj='\ip -d -s -j -p'
alias ipln="\ip -j link show | jq -r '.[].ifname'"
alias nf=nft
# alias P='parallel -i $SHELL -c "echo {} {} |& stdbuf -oL sed \"s|^|{}-\$$:\\t|\"" -- $('
alias par=parallel
alias tc='tc -col'
yt() { printf "$*\nquit" | nc localhost 5038; }
xp() { echo "$*" | xc; }
alias d2u=dos2unix
alias bd=bindkey
alias bdl='bindkey -L'
alias kc='source ~/.keychain/*-sh(.om[1])'
alias G='gdb -q -ex "b main" -ex run --args '
alias Gdb='gdb -q -ex "b main" -ex run --args '
alias Gdbr='gdb -q -ex "target remote localhost:1234"'
alias Ga='gdb -q -ex "set verbose" -ex "set sysroot /" -ex "set remote interrupt-sequence Ctrl-C" -ex "target remote :2000"'
alias Gb='gdb --nh -q --batch -ex "'
alias GG='gdbserver :2000'
alias fcp='fc -P'
alias func=function
alias fuc=function
alias fncc=functions
alias funcc=functions
alias fcc=functions
alias fcP=zloc
alias rmzl='find . -name .zsh_local_history -print -delete'
alias sc='systemctl -l'
alias sca='sudo sysctl -A | fzf -m | tr -d " "'
alias SC='sudo fdfind . /sys | fzf --multi'
alias scc=sysctl
alias sct=sysctl
alias dp=dpkg
alias dpq=dpkg-query
alias n="date '+%F %H.%M.%S'"
alias N="date '+%F %H.%M.%S.%N'"
alias nn="date '+%F__%H.%M.%S'"
alias NN="date '+%F__%H.%M.%S.%N'"
alias Nn="date '+%F %T'"
# alias nn="date '+%F__%T'"
# %H.%M.%S.%N
alias nnn='N=$( echo 00 ) ; date '+%F__%T' --date=@$(( N / 1 ))'
alias tgi=telegram-cli
alias ncn='nmcli con'
alias ndn='nmcli con'
alias ncc=nmcli
alias ncnn='nmcli dev'
alias nd='nmcli dev'
alias ncnc='nmcli con'
# alias vv=voltron
alias vv=vboxmanage
# alias k='command kill --verbose'
# alias k='kill --verbose'
alias k='kill'
alias kk='kill -STOP '
alias pf=pidof
alias fu='sudo fuser -afuv'
# alias cs='killall -STOP chrome; echo -n Chrome sleeping....; cat ; echo CONT; killall -CONT chrome'
alias cs=screen
alias sd=sysdig
alias st='strace -yyttrfs 4096 '
alias stp='strace -yyttrfs 4096 -p '
alias stt='strace_log=$(mkt strace;pwd); strace -ffo $strace_log/strace -xttrfs 4096 ; (cd $strace_log; v *)'
alias sudo='sudo '
alias uu=uniq
alias e=echo
alias vis=sudoedit
alias xrr='while :; do xrandr --output eDP-1 --gamma 0.$(($RANDOM%8+2)):0.$(($RANDOM%8+2)):0.$(($RANDOM%8+2)); read; done'
alias xR='xrandr --output eDP-2 --gamma 1:1:1'
rl() { ff=( ${@:-.} ); for f in $ff; do file $f && readlink -f $f; done ; }
alias mvo=mvO
mvO() {
for f in $*; do
if [ -e $f-OFF ]; then
mv -v -- $f-OFF $f
elif [ -e $f ]; then
if [ $f != ${f%-OFF} ]; then
mv -v -- $f ${f%-OFF}
else
mv -v -- $f $f-OFF
fi
else
echo \"$f\" not found.
fi
done
}
mvOO() { for f in $*; do mv -v -- $f $f-$(nn); done; }
mvOFF() { for f in $*; do mv -v -- $f $f-OFF; done; }
mvON() { for f in $*; do if [ -e $f-OFF ]; then mv -v -- $f-OFF $f; elif [ -e $f ]; then if [ $f != ${f%-OFF} ]; then mv -v -- $f ${f%-OFF}; else echo \"$f\" not off; fi; else echo \"$f\" not found; fi; done; }
alias sl='echo -e Loaded keys\\n-----------; ssh-add -l; echo -----------; setopt nopipefail; for key in ~/.ssh/hosts/**/*.key; do ssh-add -c $key; done'
alias sL='tabs 15; for key in /etc/ssh/ssh_host_*(.)pub; do print -n ${key:t}\\t; ssh-keygen -lf $key; done'
alias shk='( umask 077; ssh-keygen -t ed25519 -f id -N "" -C $USER@$HOST@ )'
alias skg='( umask 077; ssh-keygen -t ed25519 -f id -N "" -C $USER@$HOST@ )'
# alias sshl="ssh -p 22222 $USER@localhost"
alias sshl='ssh -o PermitLocalCommand=yes'
alias ssha=ssh-add
alias ssal='ssh-add -l'
alias sal='ssh-add -l'
alias sall='ssh-add -L'
alias salL='ssh-add -L'
alias saL='ssh-add -L'
alias ssa=ssh-add
alias ssk=ssh-keygen
alias sshx='ssh -O exit'
alias xssh='ssh -O exit'
alias xs='ssh -O exit'
rssh() { ssh -O check $1; ssh -O exit $1; ssh $1 id; ssh -O check $1; }
alias Rssh=rssh
alias Cssh='ssh -o ControlMaster=yes'
alias cssh='ssh -O check'
alias sshc='ssh -O check'
alias sshk='ssh-keyscan localhost 2> /dev/null | tee /dev/stderr | ssh-keygen -vlf - | sed "s:^[0-9]*:Fingerprint :"'
alias sshkl='ssh-keyscan localhost 2> /dev/null | tee /dev/stderr | ssh-keygen -vlf - | sed "s:^[0-9]*:Fingerprint :"'
alias sshc='ssh-copy-id -n -i ~/.ssh/id_rsa.pub'
alias sskg='echo ssh-keygen -t ed25519 -N "" -f id -C $USER@$HOSTNAME@'
alias sa='agents=( {/tmp,$TMPDIR}/ssh-*/agent.*(Nom)) ; typeset -p agents ; export SSH_AUTH_SOCK ; for SSH_AUTH_SOCK in $agents; do echo Trying $SSH_AUTH_SOCK; ssh-add -L && break; done '
alias saa='printenv SSH_AUTH_SOCK'
alias sll='. ~/.keychain/$HOST-sh; sl'
alias Rl='ranger ~/INCOMING'
alias dcl='dynamic-colors cycle'
alias dd='dd status=progress conv=fdatasync'
# alias hc=herbstclient
alias hc=hcitool
alias cts=curl-tesseract
alias gdb='gdb -q'
alias x0='if [[ -z $DISPLAY ]]; then echo Setting DISPLAY. ; if [[ -z $SSH_CONNECTION ]]; then export DISPLAY=:0 ; else export DISPLAY=localhost:10.0; fi ; fi ; printenv DISPLAY; xprop -root'
alias x00='export DISPLAY=:0; printenv DISPLAY; xprop -root'
alias x000='export DISPLAY=localhost:10.0; printenv DISPLAY; xprop -root'
alias digx='dig -x'
alias digxx='dig -x'
alias dixx='dig -x'
alias digr='dig -x'
alias y=yum
alias ZS='sudo -E $SHELL'
src_index() {
# find . \
# -type f \
# -name .repo -prune -o \
# -name .git -prune -o \
# -name out -prune -o \
# -name build -prune -o \
# -type f \( \
# -name '*.c' -o \
# -name '*.cc' -o \
# -name '*.cpp' -o \
# -name '*.h' -o \
# -name '*.hpp' \
# \) > cscope.files
setopt clobber
# TODO: Does not work?
# git ls-files -x '*.tff'
git ls-files | grep -v 'tff$' > cscope.files
cscope -bi cscope.files
}
alias s3=sqlite3
alias s3b='sqlitebrowser -R'
alias s3q='sqlitebrowser -R'
alias s3l='sqlitebrowser -R'
alias file='file -z'
alias d2='dnf-2'
alias sx='screen -X'
alias sxt='sx title'
alias ssv2csv="sed -re 's/([^ \"]*|\"[^\"]*\") /\1,/g; s/\"([^\"]*)\"/\1/g'"
alias slp=sleep
alias slpp='sleep 0.9'
alias rs=rsync
alias rsy=rsync
alias ry=rsync
alias ws=wireshark
alias wsl='wireshark -r ~/.pcaps/*.pcap(om[1]) &'
# export WS_OPTIONS=(-o tcp.no_subdissector_on_error:false -d tcp.port==1-65535,ssl -o ssl.keylog_file:/home/dsf/PCAPS/all-pcaps.keylogfile)
# export WS_OPTIONS=(-o ssl.keylog_file:/home/dsf/PCAPS/all-pcaps.keylogfile)
alias lvs='tmux split -d lnav ssldebug'
alias tsv='truncate -s0 ssldebug'
alias ww='${WIRESHARK:-wireshark} $=WS_OPTIONS $=WS_DISABLE_PROTO -o ssl.debug_file:/dev/null -r cap.pcap &'
alias wwss='${WIRESHARK:-wireshark} $=WS_OPTIONS $=WS_DISABLE_PROTO -o ssl.debug_file:/dev/stdout -r cap.pcap'
alias wws='${WIRESHARK:-wireshark} $=WS_OPTIONS $=WS_DISABLE_PROTO -o ssl.debug_file:ssldebug -r cap.pcap & truncate -s0 ssldebug'
alias wwso='${WIRESHARK:-wireshark} $=WS_OPTIONS $=WS_DISABLE_PROTO -o ssl.debug_file:ssldebug-orig -r cap.pcap & truncate -s0 ssldebug-orig'
alias sshn='ssh -o ControlMaster=no -o ControlPath=/dev/null'
alias trim="sed -e 's,^[[:blank:]]*\(.*\)[[:blank:]],\1,'"
alias xpidof='xprop _NET_WM_PID | cut -d= -f2 | trim'
alias xpf=xpidof
alias xps='ps axu gg $(xpidof)'
alias pss='gdb -batch -q -ex "set confirm off" -ex "set height 0" -ex "info shared" -ex "quit" -p '
alias gbt='gdb -batch -q -ex "set confirm off" -ex "set height 0" -ex "thread apply all bt" -ex "quit" -p '
# TODO: make C a zle binding
alias Q='cool-retro-term --fullscreen -e /usr/bin/tmux attach DN &; sleep 0.3; clear'
alias RR=reset
alias H='cd ~/.ssh/HOSTS/'
alias Hk='cd ~/.ssh/keys/'
alias 1='ping -c 100 -A 1.1.1.1'
alias p3n='ping ff02::1%'
alias p3r='ping ff02::2%'
alias p6n='ping ff02::1%'
alias p6r='ping ff02::2%'
alias 11='ping -W2 -c 100 -A 2606:4700:4700::1111'
alias 111='ping -W2 -i0.2 1.1.1.1'
alias 1n='nping -p 443 1.1.1.1'
alias 2='traceroute 1.1.1.1'
alias 3='dig one.one.one.one @1.1.1.1'
alias 4='dig one.one.one.one @127.0.0.1'
alias 8='ping -W 1 -c 100 -A 8.8.8.8'
alias 88='ping -W 1 -c 100 -A 2001:4860:4860::8888'
alias 8888='ping -W 1 -i0.2 8.8.8.8'
alias 888='8 | pre "IPv4: " & 88 | pre "IPv6: "'
alias 8n='nping --tcp-connect -p 443 8.8.8.8'
alias 9="ping -W 1 -c 1000 -A \$(ip -j route get 1.1.1.1 | jq -r \".[].gateway\")"
alias 99="ping -W 1 -c 1000 -i 0.5 \$(ip -j route get 1.1.1.1 | jq -r \".[].gateway\")"
alias 9n="nping --tcp-connect -p 80 -c 5 \$(ip -j route get 1.1.1.1 | jq -r \".[].gateway\")"
alias 89='paste <(8 -c 50) <(9 -c 50)'
alias 89n='paste <(8n -c 50) <(9n -c 50)'
# alias 0='ping $(\ip route show default | head -1 | sed -nE "s:^.* via ([.:0-9]*) .*$:\1:p") # ping next hop'
alias rf='rfkill block all'
alias rff=rfkill
alias rfw='rfkill unblock wifi'
alias rfW='rfkill block wifi'
alias rfb='rfkill unblock bluetooth'
alias rfB='rfkill block bluetooth'
alias uf='uftrace --no-pager'
alias ufr='uftrace --no-pager record -A . -R . '
alias se=set
# alias x='xeyes -outline \#$(rand_color) -fg \#$(rand_color) -center \#$(rand_color) $(rand_geom) &'
alias x=xeyes
alias vi=virsh
alias vir=virt-
alias vc=virt-customize
alias vcc='virt-customize -d $vm'
alias pk='pkill -ex'
alias ka='killall -v'
alias p.t="curl -s 'http://pass.telekom.de/' -H 'User-Agent: Mozilla/45.0 (X11; Linux x86_63)' | xmllint --html --xpath '/html/body/div[2]/div[2]/div[1]/div/div[3]' - 2> /dev/null | sed -e 's/<[^>]*>//g' "
alias mnt='mount -o ro'
# alias sdd=systemd
# alias ssd=systemd
# alias sy=systemd
alias sr=systemd-resolve
alias rc=systemd-resolve
alias gp=gpg
alias gpc=gpgconf
alias gpc=gpg-connect-agent
alias gpa=gpg-connect-agent
alias fm='findmnt --real --raw'
alias fmd='findmnt --df'
alias jr='journalctl -f -u'
alias jc=journalctl
alias sf=sshfs
alias cu=curl
alias cur=curl
alias fj=frida
alias fr=frida
alias AA='xrandr --verbose --output DP-2-1 --auto --output DP-2-2 --auto --output DP-2-3 --auto --output eDP-1 --auto --output HDMI-2 --auto --output HDMI-1 --auto --output DP-2 --auto --output DP-1 --auto'
alias AO='xrandr --output HDMI-2 --off --output HDMI-1 --off --output DP-2 --off --output DP-1 --off --verbose --output DP-2-1 --off --output DP-2-2 --off --output DP-2-3 --off --output eDP-1 --auto'
alias xk='wmctrl -ic $(xwininfo| sed -nE "s/^.*Window id: (0x[0-9a-d]*).*$/\1/p")'
alias ci=criu
alias lsof='sudo lsof +c0 -P -n'
alias lsofi='sudo lsof +c0 -P -n -i :'
alias lsofil='sudo lsof +c0 -P -n -i -a -sTCP:LISTEN,'
alias lsofii='sudo lsof +c0 -P -n -sTCP:LISTEN, -a -i'
alias lsofp='sudo lsof +c0 -P -n -p'
alias fp=fping
alias dpp=docker-packer
alias pa=patool
alias s=ssh
alias psl="psql -Aqtc"
alias py3=python3
alias pod=podman
alias podd=podman-compose
settime() {
set -e
local url="https://1.1.1.1"
local diff_ok=2
local curl_time="$( curl --silent --output /dev/null --dump-header - $url | sed -n 's.^[Dd]ate: ..p' )"
[ -z "$curl_time" ] && { echo "Failed to curl time from $url"; return 1; }
local curl_time_seconds=$( date --date "$curl_time" '+%s' )
local local_time=$( date -u '+%s' )
local diff=$(( local_time - curl_time_seconds ))
[ $diff -lt 0 ] && diff=$(( diff * -1 ))
[ $diff -lt $diff_ok ] && { echo "Local time is ok (diff to $url is less than $diff_ok seconds)."; return 0; }
echo "Local time has offset to $url of $diff seconds."
[ "$update" != "yes" ] && { echo "Only dry-run. Set update=yes to update localtime."; return 0; }
sudo date -u --set="$curl_time"
echo "Successfully set local time."
}
alias setd='update=yes settime'
alias U=usbip
alias pe=printenv
# alias units="\units --verbose '"
alias u="\units --verbose '"
alias g2=grub2-
alias ssl=openssl
alias sss=sssh
sssh() {
now() { date '+%s' }
host=$1
host_color=colour$[0x$(echo $host | md5sum | cut -c 1-2)%256]
while :; do
connect_time=$( now )
ssh -t $host "if tmux has-session 2>/dev/null; then tmux attach; else tmux new-session \"tmux set-option -g status-bg $host_color; $SHELL\" ; fi " && break
# TODO: Update to notify-send.py?
(( $( now ) - connect_time > 5 )) || {
notify-send -u critical "Lost connection to \"$host\"."
slp=$(( (2 + $RANDOM % 19) / 3.4 ))
printf "Trying to reconnect to \"$host\" in %.2f seconds: " $slp | ts -m '[%F %T]'
sleep $slp
}
done
}
mssh=(localhost)
mssh() {
while [[ $1 = -* ]]; do ssh_opt+=$1; shift; done
mssh_cmd=$*
[[ -z $mssh_cmd ]] && { echo "usage: mssh CMD (for hosts from env mssh)"; return 1; }
setopt nomonitor
local o=$(mktemp -dp . tmp-mssh-$(nn)-XXXXX)
typeset -p mssh_cmd > $o/cmd
# Dynamic tabs skrew up the output of fzf on tmux-log
# local y=( /(e'{reply=("$mssh[@]")}'nOe'{REPLY=$#REPLY}') ); tabs $(( $#y[1] + 1 ))
local h; for h in $mssh; do
ssh -o ConnectionAttempts=3 \
-o ConnectTimeout=1 \
-o BatchMode=yes \
$ssh_opt $h $@ |& tee $o/$h | sed "s:^:$h\t:" &
# Try to archive mostly sorted output but still
# allow laggy host to not delay overall execution
sleep 0.1
done
wait
}
alias zzzz='while :; do print -n .; sleep 0.2; done'
alias Z=zzzz
alias ZZ=zzzz
alias b=bridge
# alias p3='python3.8'
alias p3=python3
alias tsh=tshark
# alias tsl='tshark -r $pcap -qz expert -z io,phs'
alias tsl='tshark -r $pcap -nq -z expert -z conv,udp -z conv,tcp -z io,phs'
alias nw=notmuch
alias i3m='i3-msg -s $(echo /var/run/user/1000/i3/ipc-socket*(om[1]))'
# i3t() { i3-msg -s $(echo /var/run/user/1000/i3/ipc-socket*(om[1])) rename workspace to $1; i3-ws-enum ; }
alias ki=kitty
alias kit=kitty
alias K=kitty
TT() { nvim +'norm i' term://"$*" ; }
T() { nvim term://"$*" ; }
alias ng=noglob
alias Pi='ping -D -W 1 -i 0.2 '
alias gvv='nvim +GV\ --all'
alias nmm='nm --defined-only -l'
alias mz=mausezahn
alias ns=netsniff-ng
alias i=ip
alias pst='pstree -lp'
alias ne=neomutt
alias V=v4l2ctrl
alias v2=v4l2ctrl
alias zat='zathura --fork'
alias dm='sudo dmsetup'
alias cr=cryptsetup
alias cry=cryptsetup
alias PI='pip3 install --user -vvv'
alias ju=jupyter
alias ptp=ptpython
alias rzsh='sudo HOME=$HOME zsh'
alias rz='sudo -E HOME=$HOME zsh'
alias xdft='xdg-mime query filetype '
alias xdft='xdg-mime query filetype '
alias sup=supermin
alias chx='sudo chmod +x'
alias chnox='sudo chmod -Rc -x'
alias chnx='sudo chmod -Rc -x'
alias chmer='sudo chown -c -R $(id -u):$(id -g) .'
alias chme='sudo chown -c $(id -u):$(id -g)'
alias chu='sudo chown -c $(command stat -c "%U:%G" .) .'
alias chur='sudo chown -c -R $(command stat -c "%U:%G" .) .'
alias lo='losetup --find --show'
alias los=losetup
SB() { supermin -v --build $1 --include-packagelist -f ext2 -o ${1%.s}.a ; }
xdD() {
[ $# = 2 ] || { echo "xdD example_file program"; return ; }
xdg-mime default ${2##*/} $(xdg-mime query filetype $1)
}
alias cdz=fzc
alias sq=seq
alias ca=cat
pad() { patool create $1.tgz $1 ; }
# TODO: find base85/91 implementation
padd() { tar czf - $* | base64 | $=XC ; }
paxx() { $=XP | base64 -d -i | tar xkzvf - ; }
paxp() { cat | base64 -d -i | tar xkzvf - ; }
alias PA="$XP"
cvv() { setopt pipefail; dir=$(dirs -l -p -v | fzf | cut -f 2) && cd $dir || echo "$funcstack[1] aborted..." ; }
alias cvc=cvv
alias xi=xinput
alias xin=xinput
alias os=openssl
alias xq='xset q'
alias blc=bluetoothctl
alias bl=bluetoothctl
alias cm=command
alias cmd=command
alias un=unset
alias uns=unset
alias unse=unset
alias unsp='export PAGER='
alias psc='ps -O ppid,cgroup, '
alias torr=torsocks
alias um='sudo umount'
alias umt='sudo umount'