forked from atomantic/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.shellaliases
924 lines (783 loc) · 34.4 KB
/
.shellaliases
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
#!/bin/sh
# find lines only in file1
function only_left() {
comm -23 <(sort <(grep '^[^#]' $1)) <(sort <(grep '^[^#]' $2))
}
# find lines only in file2
function only_right() {
comm -13 <(sort <(grep '^[^#]' $1)) <(sort <(grep '^[^#]' $2))
}
# find lines common to both files
function common_to_both() {
comm -12 <(sort <(grep '^[^#]' $1)) <(sort <(grep '^[^#]' $2))
}
function uncommon_left() {
common_to_both $1 $2 > asd
only_left $1 asd
}
function uncommon_right() {
common_to_both $1 $2 > asd
only_right $1 asd
}
function pass_insert(){
expect << EOF
spawn $1
expect {
"Enter contents of" {send "$2"; send "\x04"}
}
expect eof
EOF
}
###############################################################################
# Development section
###############################################################################
alias getlogos='for t in $(cat techs); do echo -e "${t}\n";curl -s https://logosear.ch/api/search.json\?q\=$t\&max\=48 | jq .results[].url -r >> logolist; done'
alias getlogos.download='aria2c --max-connection-per-server=16 --min-split-size=1M --input-file=logolist'
# linux xorg copy/paste implementation - mirroring the macos commands
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
# pipe the destination machines clipboard to local clipboard
alias osxnetwork-paste='ssh OSX_MACHINENAME.local pbpaste | pbcopy'
# pipe the local clipboard to the destination android device using termux sshd and termux-api
alias android-paste='pbpaste | ssh android.local termux-clipboard-set'
alias vps="mosh --ssh='ssh -C -i ~/.ssh/tgroch_id_rsa' [email protected] bash"
alias findd="fd $@"
# https://dev.to/maxpou/git-cheat-sheet-advanced-3a17
# ✔ Custom commits
# # Edit last commit
# git commit --amend -m "A better message"
# # Add something to the last commit without writing message again
# git add . && git commit --amend --no-edit
# # empty commit - can be useful to re-trigger CI build...
# git commit --allow-empty -m "chore: re-trigger build"
alias lg="lazygit"
alias hn="hackernews_tui"
alias git_branch="git checkout -b $@ > /dev/null 2>&1 || git checkout $@"
alias new_feature="git_branch features/$@"
alias new_hot_fix="git_branch hot-fixes/$@"
alias new_patch="git_branch patchs/$@"
function sync_all(){
rsync -rtavuc --delete --progress ${1}/.[^.]* ${2}
}
alias youtube="rm ~/.config/mps-youtube/cache_py_* 2>&1 >/dev/null; mpsyt"
alias s="sublimetext"
alias weather="curl -s 'http://wttr.in/Florianopolis?lang=pt'"
alias weather2="curl -s 'http://v2.wttr.in/Florianopolis?lang=pt'"
alias tempo="weather"
alias tempo2="weather2"
alias qrcode="curl qrenco.de/$@"
alias hollywood='docker run --rm -it bcbcarl/hollywood'
alias browser='docker run --rm -it browsh/browsh:latest'
alias audit_this_site='docker run --rm -it trailofbits/twa -vw '
alias nogiveup="curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash"
alias starwars="telnet towel.blinkenlights.nl"
alias world="telnet mapscii.me"
alias parrotdance="curl parrot.live"
alias criptorates="curl rate.sx"
alias zsh.debug="zsh -xv"
alias neofetch="neofetch --config none"
# https://quadpoint.org/articles/irssi/
# alias irc="screen -r $(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/\((Detached)\|(Multi, detached)\|(Multi, attached)\)// p') || ! test -z $(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/\((Attached)\)// p') || screen -S irc irssi"
alias irc="screen irssi"
# For HTTP connection set the following alias:
alias dockerx="docker -H=174.138.49.215:2375"
# Ngrok share with site parameter
# usage: share_webapp
share_webapp() {
local localHostName="${$(pwd)##*/}"
ngrok http -subdomain devgiga \
-host-header=rewrite $localHostName:80
}
dot_link() {
mv $1 $MY_DOTFILES/homedir/
ln -s "$MY_DOTFILES/homedir/$1" $1
}
alias dotfiles='git --git-dir=${BARE_DOTFILES}/ --work-tree=$HOME'
alias dot='dotfiles'
# Cheat sheets
alias dterm="curl -s -X GET https://raw.githubusercontent.com/LeCoupa/awesome-cheatsheets/master/languages/bash.sh | less"
alias dtmux="curl -s -X GET https://gist.githubusercontent.com/MohamedAlaa/2961058/raw/ddf157a0d7b1674a2190a80e126f2e6aec54f369/tmux-cheatsheet.markdown | less"
alias ddocker="curl -s -X GET https://raw.githubusercontent.com/LeCoupa/awesome-cheatsheets/master/tools/docker.sh | less"
alias dvim="curl -s -X GET https://raw.githubusercontent.com/LeCoupa/awesome-cheatsheets/master/tools/vim.txt | less"
alias djavascript="curl -s -X GET https://raw.githubusercontent.com/LeCoupa/awesome-cheatsheets/master/languages/javascript.js | less"
alias dnode="curl -s -X GET https://raw.githubusercontent.com/LeCoupa/awesome-cheatsheets/master/backend/node.js | less"
alias kb="kubectl"
alias mk="minikube"
alias p="gopass $@"
alias shellconf="EDITOR=subl pass edit shell/vars"
# usages:
# genpass "sites/example.com"
# genpass "sites/example.com" 8 "username"
function genpass {
source $HOME/lib_sh/echos.sh
entry=$1
url=$(echo $entry| sed -e 's/.*\///g')
user=${3:-$GIT_AUTHOR_EMAIL}
password_length=${2:-16}
running "generating ${entry} password.."
expect << EOF
spawn gopass generate $@ --force
sleep 1
expect "How long should the password be?"
send -- "$password_length"
send "\r"
expect "Do you have strict rules to include different character classes?"
send "N\r"
expect "Do you want to continue?"
send "y\r"
expect eof
EOF
ok
running "setting user.."
printf "${user}" | gopass insert $entry user;ok
running "setting user.."
printf "${url}" | gopass insert $entry url;ok
# read -t 7 -r -p "Auto sync? (y|N) [default=y] " response; echo ;
echo "Auto sync? (y|N) [default=y] "
read -t 7 -r response; echo ;
response=${response:-y}
if [[ $response =~ (yes|y|Y) ]];then
gopass sync
fi
}
alias pass_update="gopass update --no-symbols --clip $@"
# PHP
# alias phptags="sh ~/.scripts/phpctags"
# alias phptags_vendor="sh ~/.scripts/phpctags_vendor"
alias nmap="nmap --spoof-mac 0 $@"
# Ping scan only: -sP
# Don't ping: -PN
# TCP SYN ping: -PS
# TCP ACK ping: -PA
# UDP ping: -PU
# ARP ping: -PR
# alias nmap.router="sudo nmap -v -sT -PN 192.168.0.1 --spoof-mac 0 -D 10.0.0.1,10.0.0.2,10.0.0.4"
alias nmap.router="sudo nmap --osscan_guess -v -sT -PN 192.168.0.1 --spoof-mac 0 -D 10.0.0.1,10.0.0.2,10.0.0.4"
function nmap_enumerate {
SUBNET="${1:-192.168.100}.0/24"
echo "Enumerating on $SUBNET\n"
sudo nmap -snA $SUBNET
}
# usages:
# nmap_local_subnet 192.168.0 [|only_ips]
function nmap_local_subnet {
# TCP Null Scan
SUBNET="${1:-192.168.0}.0/24"
echo "Looking on $SUBNET\n"
nmap -sn $SUBNET
}
alias whoarehere="nmap_local_subnet $@"
alias marco="whoarehere $@"
function nmap_check_win_vunerable {
nmap -Pn -p445 --script=smb-vuln-ms17-010 192.168.0.0/24 -oN eternalblue-scan.txt
cat eternalblue-scan.txt | grep VULNERABLE
}
# nmap -T4 -A 192.168.0/24
# nmap -T4 -A 192.168.0/24
# nmap -T4 -p- -iL ips.tx
alias only_ips='grep -Eo "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | sort -u '
alias ping="prettyping -i 2 $@"
alias lping="prettyping -i 20 $@"
alias arduino="/Applications/Arduino.app/Contents/MacOS/Arduino"
# sudo tail -f /dev/ttyACM0
# sudo chmod a+rw /dev/ttyUSB0
# ttyUSB1
# ttyACM0
# ttyACM1
# ttyS0
alias lynda="youtube-dl $@ --username [email protected] --password Hero30888899 --output \"%(playlist_title)s/%(autonumber)s.%(title)s.%(ext)s\" --all-subs --autonumber-size 2"
# Apps
alias jumpcutter="exec ${HOME}/dev/jumpcutter/run.sh $@"
alias notify="npx node-notifier-cli notify --title 'Notification' -s --open $@"
alias typora="open -a typora"
alias zettlr="open -a zettlr"
alias ff="fuck $@"
alias mtop="glances"
alias ntop="sudo iftop"
alias networktop="ntop"
alias toggle-hot-corner="toggle-hot-corner.sh"
alias code.photo="carbon-now $@"
alias f.create_usb_macos_installer="create-macos.sh $@"
alias f.create_usb_udf_format="create-udf.sh $@"
alias inspect="npx -q nodejs-dashboard $@"
alias ffind="afind --ignore-dir={vendor,node_modules} $@"
function take_my_wifi {
SSID="$(sudo npx osx-wifi-cli)"
PASS="$(npx wifi-password-cli)"
SSID=${SSID:21:-1}
npx qrcode "WIFI:T:WPA;S:${SSID};P:${PASS};;"
}
saythis() {
say -v 'Tom' $1
}
alias ok="saythis done!"
alias falar="espeak -v pt-br $@"
alias temp="dev && mkdir -p temp && cd temp"
alias temp.rm="dev && rm -Rf temp"
# Home
alias snap="imagesnap -q -w 3 .jpg"
alias tb="nc termbin.com 9999 | pbcopy"
alias a.ssh="waitforssh.sh $@"
alias desktop="cd ~/Desktop"
alias desk="desktop"
alias olx="cd ~/olx"
alias dev="cd ${MY_CODE}"
alias pi="cd ~/pi"
alias blog="cd ${MY_BLOG}"
alias blog.write="zettlr $MY_BLOG/portfolio"
alias blog.pretty.code="code.photo -p blog-master-present $@"
alias d.fix_video="jumpcutter"
alias a.diff="$EDITOR_DIFF"
alias vtop="npx -q vtop"
alias a.onchange="npx -q onchange"
alias a.onerror="npx -q onerror"
alias a.find_empty_dirs="find . -type d -empty -print"
alias a.rm_empty_dirs="find . -type d -empty -delete"
alias a.inspect="inspect $@"
alias not="notify $@"
alias blog.rec=blog_rec.sh $@
alias dotfiles_update="cd && git fetch upstream && git checkout master && git merge upstream/master"
function docker_reset {
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker network rm $(docker network ls -q)
docker volume rm $(docker volume ls -q)
docker system prune --all --force
}
function exploit_this_cms {
temp && $(ls vulnx || git clone https://github.com/anouarbensaad/VulnX.git vulnx)
cd vulnx
docker build -t vulnx ./docker/
docker run --rm -it vulnx:latest -u $1
}
## run_this_container [git_repo] [image] [path_to_Dockerfile] vulnx:latest [params]
## run_this_container https://github.com/anouarbensaad/VulnX.git vulnx ./docker/ "-u https://herospark.com/blog/"
# function run_this_container {
# temp && $(ls asd > /dev/null || git clone $1 asd)
# cd asd
# docker build -t $2 $3
# docker run --rm -it $2 $4
# }
# Dev
alias encriptar="gpg --encrypt --recipient [email protected] "
alias decriptar="gpg --decrypt "
alias pid_gpg_agent="pgrep -x gpg-agent"
# The export command below gives you the key you add to GitHub
alias gpg_export="gpg --armor --export $@"
alias "mynexts"='echo "Finding issues available for contributing, based on my ⭐️ repositories...\n"; docker run -e TOKEN=$MIGHTY_WATCHER_GITHUB_TOKEN --rm igorperikov/mighty-watcher:latest'
# Lock the screen (when going AFK)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
alias sl="lf $@"
alias j="colorls --long --group-directories-first --almost-all --git-status"
alias l="lsd -la"
alias qq="cat ~/.zsh_history | grep "
alias ww="which "
alias ee="open https://litewrite.net/"
# Make some possibly destructive commands more interactive.
# alias rm='rm -v'
alias mv='mv -v'
alias cp='cp -v'
# has checks presence of various command line tools on the PATH and reports their installed version.
alias has="curl -sL https://git.io/_has | bash -s"
# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'
# Copy and paste and prune the usless newline
alias pbcopynn='tr -d "\n" | pbcopy'
# Reload the shell (i.e. invoke as a login shell)
alias reload="exec \$SHELL -l"
alias launchpad.save="lporg save ~/.launchpad.yaml && dot && git add homedir/.launchpad.yaml && git commit -m '♻️ - Launchpad updated' && git push"
alias jsonfix="pbpaste | jq . | pbcopy"
alias curl.download="curl -L -O -C - "
alias down="aria2c --max-connection-per-server=16 --min-split-size=1M "
alias "?"="tldr"
alias "??"="curl cheat.sh/$@"
alias td="todo.sh"
alias tda="todo.sh add"
alias tdl="todo.sh list"
alias tdd="todo.sh do"
# Empty the Trash on all mounted volumes and the main HDD.
# Also, clear Apple’s System Logs to improve shell startup speed.
# Finally, clear download history from quarantine. https://mths.be/bum
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
alias stremio_flush_cache="/bin/rm -Rf ~/Library/Application\ Support/stremio-server/stremio-cache/*"
alias disk_usage="ncdu"
alias net_usage="sudo iftop"
alias net_watch="sudo ngrep -d any"
###############################################################################
# Git section
###############################################################################
alias gitsubmoduleinit="git submodule update --init --recursive"
function gitmoji_switch_stack {
pushd $HOME/.gitmoji > /dev/null 2>&1
rm -f gitmojis.json
if [[ -r "gitmojis-${1}.json" ]]; then
ln -s gitmojis-$1.json gitmojis.json
else
echo "$HOME/.gitmoji/gitmojis-${1}.json not found."
fi
popd > /dev/null 2>&1
# Process all arguments except the first one
[[ -r "$HOME/.gitmoji/gitmojis.json" ]] && gitmoji "${@:2}"
}
alias gitmoji_en="gitmoji_switch_stack default"
alias gitmoji_br="gitmoji_switch_stack br"
alias autocommit_en="gitmoji_en --commit"
alias autocommit="gitmoji_br --commit"
# Git Tools
# assumes git-up is installed (gem install git-up)
# switches to 'develop' branch, updates all local branches (nicely using git-up), removes all local branches already merged into 'develop'
alias gitdev='git checkout develop; git-up; git branch --merged develop | grep -v "\* develop" | xargs -n 1 git branch -d; git branch;'
# GIT
alias g=git
alias gss='git status -s'
alias ggs="${MY_DOTFILES}/scripts/git-summary $@"
alias ggss="npx git-summary; npx git-summary --line"
alias gs="git status"
alias gcom="git checkout master"
alias gaa="git add ."
alias gc="git commit -m "
alias gp="git pull"
alias gpp="git push"
alias gacp="git add . && git commit --allow-empty-message && git push origin"
alias gac="git add . && git commit --allow-empty-message"
alias gpull="git pull origin"
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias glg='git log --stat'
alias glgp='git log --stat -p'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate'
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias gd="git-icdiff ${GIT_DIFF_OPTIONS:-}"
alias gdi='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff'
alias nah="git reset --hard && git clean -df"
# cp repo
# git remote add personal https://gitlab.com/asd/qwe.git
# git push personal
alias logfun="tail -f /var/log/nginx/access.log | logstalgia --sync"
alias tails="less +F " # or tail -250f
# Laravel
alias laratail='tails $(find storage/logs | tail -n 1)'
alias laratest="php artisan config:clear && phpunit"
alias laratestrand="php artisan config:clear && $HOME/.composer/vendor/fiunchinho/phpunit-randomizer/bin/phpunit-randomizer --colors --order rand"
alias pacc="php artisan config:cache"
alias pacl="php artisan config:clear"
alias pas="php artisan serve"
# alias composer="docker run -v $(pwd):/app -w /app composer"
# docker run -v $(pwd):/app -w /app composer
# docker run -v `pwd`/src:/src composer create-project --prefer-dist laravel/laravel src/$1
alias npm_cache_proxy="docker run -e REDIS_ADDRESS=host.docker.internal:6379 -p 6660:8080 -it -d pkgems/npm-cache-proxy && npm config set registry http://localhost:6660"
alias npm_cache_proxy_off="npm config set registry "
alias run="npm run $@"
# push git repo, but first, use git-up to make sure you are in sync and rebased with the remote
alias pushup="git-up && git push"
# buzzphrase commit
# used for my presentation decks when I have nothing to say about the commit
alias bpc='git add -A . && git cam "$(buzzphrase 2)" && git push'
# backup without stash files before you switch branches
function git_backup {
mkdir -p .config-backup && \
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
xargs -I{} mv {} .config-backup/{}
}
###############################################################################
# Sysadmin section
###############################################################################
function mkreadonly(){
echo -n '' > $1 && \
chmod 444 $1
}
# function defaults_debug() {
# before=$(defaults read $1)
# echo "Now set the new config"
# echo -n "Press any key to continue..." && read
# after=$(defaults read $1)
# colordiff <(echo "${before}" ) <(echo "${after}" )
# if [[ $? = 0 ]]; then
# echo "nothing changed."
# fi
# }
# Disable Spotlight
alias spotoff="sudo mdutil -a -i off"
# Enable Spotlight
alias spoton="sudo mdutil -a -i on"
# recursive dos2unix in current directory
alias dos2lf='dos2unix `find ./ -type f`'
# Files being opened
alias files.open='sudo fs_usage -e -f filesystem|grep -v CACHE_HIT|grep -v grep|grep open'
# Files used, anywhere on the filesystem
alias files.usage='sudo fs_usage -e -f filesystem|grep -v CACHE_HIT|grep -v grep'
# Files in use in the Users directory
alias files.usage.user='sudo fs_usage -e -f filesystem|grep -v CACHE_HIT|grep -v grep|grep Users'
# Set the extended MacOS attributes on a file such that Quicklook will open it as text
alias qltext='xattr -wx com.apple.FinderInfo "54 45 58 54 21 52 63 68 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" $1'
#alias qltext2='osascript -e tell application "Finder" to set file type of ((POSIX file "$1") as alias) to "TEXT"'
# Crontab auto reload
if test -z $CRONTABCMD; then
# allows to source zshrc twice
export CRONTABCMD=$(which crontab)
crontab()
{
if [[ $@ == "-e" ]]; then
$EDITOR ~/.crontab && $CRONTABCMD ~/.crontab
else
$CRONTABCMD $@
fi
}
$CRONTABCMD ~/.crontab
fi
alias listlinks='gls -l --color | grep "\->"'
alias lsln='gls -l | grep "\->" | while read fname
do
echo "$fname" # your code goes here
done'
###############################################################################
# Service section
###############################################################################
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias nginx.config='sudo $EDITOR /usr/local/etc/nginx/valet/valet.conf'
alias nginx.config='$EDITOR /usr/local/etc/nginx/valet/valet.conf'
alias nginx.configtest='sudo nginx -t'
alias php.start="sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.php71.plist"
alias php.stop="sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.php71.plist"
alias php.restart='php-fpm.stop && php-fpm.start'
alias mariadb.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist"
alias mariadb.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist"
alias mariadb.logs="tails /tmp/mysql.log"
alias mysql.new='mysql -uroot -e "CREATE DATABASE IF NOT EXISTS $1;"'
alias mysql.rm='mysql -uroot -e "DROP DATABASE IF EXISTS $1;"'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
# newest log file matching
alias mariadb.logs='tails /var/log/mysql/all.log'
alias ci.logs='tails $(ls -t application/logs/log-* | head -1)'
alias nginx.logs.error='tails /Users/tg/.valet/Log/nginx-error.log'
alias nginx.logs.access='tails /Users/tg/.valet/Log/nginx-access.log'
alias nginx.logs.default.access='tails /usr/local/etc/nginx/logs/default.access.log'
alias nginx.logs.default-ssl.access='tails /usr/local/etc/nginx/logs/default-ssl.access.log'
alias nginx.logs.phpmyadmin.error='tails /usr/local/etc/nginx/logs/phpmyadmin.error.log'
alias nginx.logs.phpmyadmin.access='tails /usr/local/etc/nginx/logs/phpmyadmin.access.log'
# brew uninstall --ignore-dependencies node icu4c; brew install node; brew link --overwrite node
# fixes this problems
# dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib
# Referenced from: /usr/local/bin/node
# Reason: image not found
alias brew.off="sudo brew services stop --all && brew services stop --all"
alias brew.on="sudo brew services start dnsmasq && \
brew services start mariadb && \
sudo brew services start nginx && \
brew services start redis && \
sudo brew services start php;"
###############################################################################
# Audit/Scan section
###############################################################################
alias stress="ab -n 10000 -c 10 "
alias loadtest="npx loadtest -c 10 --rps 200 ${@}"
###############################################################################
# RaspberryPi section
###############################################################################
alias pi.magazine="wget -A pdf -m -p -E -k -K -npc https://www.raspberrypi.org/magpi-issues/"
alias pi.findit="dns-sd -G v4 raspberrypi.local"
###############################################################################
# Network section
###############################################################################
# wget for check 404s
alias audit_for_404="wget get --spider -nd -r '$@'"
# Reboot my home Linksys WAG160N / WAG54 / WAG320 / WAG120N Router / Gateway from *nix.
alias rebootlinksys="curl -u 'admin:my-super-password' 'http://192.168.1.2/setup.cgi?todo=reboot'"
# Reboot tomato based Asus NT16 wireless bridge
alias reboottomato="ssh [email protected] /sbin/reboot"
alias router='dig | grep "SERVER: "'
# firewall management
alias port-forward-enable="echo 'rdr pass inet proto tcp from any to any port 2376 -> 127.0.0.1 port 2376' | sudo pfctl -ef -"
alias port-forward-disable="sudo pfctl -F all -f /etc/pf.conf"
alias port-forward-list="sudo pfctl -s nat"
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias iplocal="ipconfig getifaddr en0"
#alias iplan="$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Show active network interfaces
#alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
# Flush the DNS on Mac
alias dnsflush='dscacheutil -flushcache;sudo killall -HUP mDNSResponder'
alias macinfo='sw_vers'
alias distroinfo='lsb_release -a'
# Show network connections
# Often useful to prefix with SUDO to see more system level network usage
alias network.connections='lsof -l -i +L -R -V'
alias network.established='lsof -l -i +L -R -V | grep ESTABLISHED'
alias network.externalip='curl -s http://checkip.dyndns.org/ | sed "s/[a-zA-Z<>/ :]//g"'
alias network.internalip="ifconfig en0 | egrep -o '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'"
# list all IPs in the connected network
function allaround(){
if=$(route -n get 0.0.0.0 2>/dev/null | awk '/interface: / {print $2}')
if [ -n "$if" ]; then
echo "Default route is through interface $if"
sudo arp-scan --interface="${if}" --localnet
else
echo "No default route found"
fi
}
function take_my_wifi {
SSID="$(sudo npx osx-wifi-cli)"
PASS="$(npx wifi-password-cli)"
SSID=${SSID:21:-1}
npx qrcode "WIFI:T:WPA;S:${SSID};P:${PASS};;"
}
function findc() {
find $1 -type f -exec grep --color=auto -nH $2 /dev/null {} +
}
alias mymail="neomutt -f /var/mail/${USER}"
function emails() {
results=$(echo "$(curl -Ls $1) $(whois $1)" | node $MY_DOTFILES/scripts/find-emails-tool/src/index.js | jq '.[].address' | sort | uniq -i)
echo "${results//\"}" | grep -vF "`cat $MY_DOTFILES/scripts/find-emails-tool/excluded_strings.txt`"
}
function cat_npm_scripts {
find . -maxdepth 2 -mindepth 2 -name "${1}" -exec cat {} | jq '.scripts' \;
}
if test -z $GITLABCMD; then
# allows to source zshrc twice
export GITLABCMD=$(which gitlab 2> /dev/null)
gitlab_init() {
json=$(gitlab create_project "$1" "{ description: '$2' }" --json)
http_url_to_repo=$(echo $json | jq .result.http_url_to_repo)
http_url_to_repo="${http_url_to_repo%\"}"
http_url_to_repo="${http_url_to_repo#\"}"
git remote add origin $http_url_to_repo
git push -u origin master
}
# gitlab_delete() {
# json=$(gitlab delete_project $1 --json)
# }
fi
function init_git {
git init
git add -A
git commit -m "Initial commit"
}
function init_npm {
npx license $(npm get init.license) -o "$(npm get init.author.name)" > LICENSE
# TODO: preserve current .gitignore
npx add-gitignore $@ node macOS windows linux sublimetext visualstudiocode
npx covgen "$(npm get init.author.email)"
npm init -y
}
alias f.rm_all_node_modules="find . -name 'node_modules' -exec rm -rf '{}' +"
alias update="pnpx -y npm-check -u"
alias u="update"
alias d="pnpm dev"
alias i="pnpm install"
alias clean="rm -Rf .temp; rm -Rf node_modules; rm -f yarn.lock; rm -f package-lock.json; rm -f pnpm-lock.yaml"
alias rm_node_modules="clean"
alias a.sort_package_json="npx sort-package-json $@"
alias a.npm_check="npx npm-check $@"
alias a.npm_check2="npx nsp check $@"
alias a.david="npx david $@"
alias a.nsp="npx nsp ${@:-'check'}"
alias a.nodemon="npx nodemon $@"
alias a.npm_run_all="npx npm-run-all $@"
alias a.webpack="npx webpack-cli $@"
alias a.yo="npx yo $@"
alias s.vue="npx vue/cli $@"
alias s.whereami="npx github:@rafaelrinaldi/whereami $@"
alias s.buzzphrase="npx buzzphrase $@"
alias s.carbon_now="npx carbon-now-cli $@"
alias s.codeceptjs="npx codeceptjs $@"
alias s.filepizza="npx filepizza $@"
alias s.fkill="npx fkill-cli $@"
alias s.get-urls="npx get-urls-cli $@"
alias s.git_open="npx git-open $@"
alias s.gtop="npx gtop $@"
alias s.instant_markdown_d="npx instant-markdown-d $@"
alias s.iponmap="npx iponmap $@"
alias s.kill_tabs="npx kill-tabs $@"
alias s.netlify="npx netlify-cli $@"
alias s.ngrok="npx ngrok $@"
alias s.now="npx now $@"
alias s.npm_check="npx npm-check $@"
alias s.npms="npx npms-cli $@"
alias s.osx_wifi="npx osx-wifi-cli $@"
alias s.pen="npx pen $@"
alias s.prettyaml="npx prettyaml $@"
alias s.prettyjson="npx prettyjson $@"
alias s.puppeteer="npx puppeteer $@"
alias s.redis_commander="npx redis-commander $@"
alias s.shorturl="npx shorturl $@"
alias s.siteaudit="npx siteaudit $@"
alias s.spoof="npx spoof $@"
alias s.surge="npx surge $@"
alias s.torrent="npx torrent $@"
alias s.empty_trash="npx empty-trash-cli $@"
alias s.ungit="npx ungit $@"
alias s.vtop="npx vtop $@"
alias s.vuepress="npx vuepress $@"
alias s.wallpaper="npx wallpaper-cli $@"
alias s.why_is_node_running="npx why-is-node-running $@"
alias s.wifi_password="npx wifi-password-cli $@"
alias s.yamlxjson="npx yamlxjson $@"
alias d.hacker_news='npx @rafaelrinaldi/hn-cli --keep-open --latest $@'
alias d.qrcode='npx qrip $@'
alias d.workin_hard='npx workin-hard $@'
alias d.image_processing='npx korkut $@'
alias d.image_mobile-gen='npx mobicon-cli $@'
alias d.game="toggle-hot-corner"
alias l.prettier="npx prettier $@"
alias l.eslint="npx eslint $@"
alias l.babel_eslint="npx babel-eslint $@"
alias l.eslint_config_standard="npx eslint-config-standard $@"
alias l.eslint_config_standard-react="npx eslint-config-standard-react $@"
alias l.eslint_config_standard-jsx="npx eslint-config-standard-jsx $@"
alias l.eslint_plugin_react="npx eslint-plugin-react $@"
alias l.eslint_config_prettier="npx eslint-config-prettier $@"
alias l.eslint_plugin_prettier="npx eslint-plugin-prettier $@"
###############################################################################
# Fun section
###############################################################################
alias game.seek='txt="";for i in {1..20};do txt=$txt"$i. ";done;txt=$txt" Ready or not, here I come";say $txt'
# A full set of cowsay aliases (includes all default cowsay options)
alias pet.cow='npx cowsay $@'
alias asdff="curl -s https://raw.githubusercontent.com/julianosirtori/Cowsay-coachdefracassos/master/frases.json | jq -r '.[] | .frase ' | sort -R | head -n 1 | npx cowsay -f www"
alias pet.cow='npx cowsay $@'
alias pet.turtle='npx cowsay $@ -f turtle'
alias pet.beavis='npx cowsay $@ -f beavis.zen'
alias pet.bong='npx cowsay $@ -f bong'
alias pet.bud_frogs='npx cowsay $@ -f bud-frogs'
alias pet.bunny='npx cowsay $@ -f bunny'
alias pet.cheese='npx cowsay $@ -f cheese'
alias pet.cower='npx cowsay $@ -f cower'
alias pet.daemon='npx cowsay $@ -f daemon'
alias pet.doge='npx cowsay $@ -f doge'
alias pet.dragon_and_cow='npx cowsay $@ -f dragon-and-cow'
alias pet.dragon='npx cowsay $@ -f dragon'
alias pet.elephant_in_snake='npx cowsay $@ -f elephant-in-snake'
alias pet.elephant='npx cowsay $@ -f elephant'
alias pet.eyes='npx cowsay $@ -f eyes'
alias pet.flaming_sheep='npx cowsay $@ -f flaming-sheep'
alias pet.ghostbusters='npx cowsay $@ -f ghostbusters'
alias pet.goat='npx cowsay $@ -f goat'
alias pet.head_in='npx cowsay $@ -f head-in'
alias pet.hedgehog='npx cowsay $@ -f hedgehog'
alias pet.hellokitty='npx cowsay $@ -f hellokitty'
alias pet.kiss='npx cowsay $@ -f kiss'
alias pet.kitty='npx cowsay $@ -f kitty'
alias pet.koala='npx cowsay $@ -f koala'
alias pet.kosh='npx cowsay $@ -f kosh'
alias pet.luke_koala='npx cowsay $@ -f luke-koala'
alias pet.mech_and_cow='npx cowsay $@ -f mech-and-cow'
alias pet.meow='npx cowsay $@ -f meow'
alias pet.milk='npx cowsay $@ -f milk'
alias pet.moofasa='npx cowsay $@ -f moofasa'
alias pet.moose='npx cowsay $@ -f moose'
alias pet.mutilated='npx cowsay $@ -f mutilated'
alias pet.ren='npx cowsay $@ -f ren'
alias pet.satanic='npx cowsay $@ -f satanic'
alias pet.sheep='npx cowsay $@ -f sheep'
alias pet.skeleton='npx cowsay $@ -f skeleton'
alias pet.small='npx cowsay $@ -f small'
alias pet.sodomized='npx cowsay $@ -f sodomized'
alias pet.squirrel='npx cowsay $@ -f squirrel'
alias pet.stegosaurus='npx cowsay $@ -f stegosaurus'
alias pet.stimpy='npx cowsay $@ -f stimpy'
alias pet.supermilker='npx cowsay $@ -f supermilker'
alias pet.surgery='npx cowsay $@ -f surgery'
alias pet.telebears='npx cowsay $@ -f telebears'
alias pet.turkey='npx cowsay $@ -f turkey'
alias pet.turtle='npx cowsay $@ -f turtle'
alias pet.tux='npx cowsay $@ -f tux'
alias pet.vader-koala='npx cowsay $@ -f vader-koala'
alias pet.vader='npx cowsay $@ -f vader'
alias pet.whale='npx cowsay $@ -f whale'
alias pet.www='npx cowsay $@ -f www'
alias lookbusy="cat /dev/urandom | hexdump -C | grep \"34 32\""
# Convert RAW images to 2560px max-dimension JPEG @ 80 quality to ./output
# check for presence of convert command first:
# if test -z $CONVERTCMD; then
# # allows to source zshrc twice
# export CONVERTCMD=$(which convert 2> /dev/null)
# function convert-raw-to-jpg() {
# local quality=${1:-80};
# local max_dim=${2:-2650};
# local source_files=${3:-*.CR2};
# echo "Usage: convert-raw-to-jpg [quality=80] [max-dimension-px=2560] [source=*.CR2]";
# echo "Converting all ${source_files} to JPEG (${quality} quality, ${max_dim}px max) to output/...";
# mkdir -p output 2> /dev/null;
# find . -type f -iname "${source_files}" -print0 | xargs -0 -n 1 -P 8 -I {} convert -verbose -units PixelsPerInch {} -colorspace sRGB -resize ${max_dim}x${max_dim} -set filename:new '%t-%wx%h' -density 72 -format JPG -quality ${quality} 'output/%[filename:new].jpg';
# echo 'Done.';
# }
# fi;
alias tor_exit_nodes="curl https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=1.1.1.1"
# find . -type f -iname '*.CR2' -print0 | xargs -0 -n 1 -P 8 -I {} convert -verbose -units PixelsPerInch {} -colorspace sRGB -resize 2560x2650 -set filename:new '%t-%wx%h' -density 72 -format JPG -quality 80 '%[filename:new].jpg'
if [[ "$(uname -s)" == "Darwin" ]]; then
alias mount_ESP="mkdir -p /Volumes/ESP && sudo mount -t msdos /dev/disk0s1 /Volumes/ESP"
elif [[ "$(uname -s)" == "Linux" ]]; then
# YAY
# Print current configuration
alias yaconf="yay -Pg"
# Install packages from the repositories
alias yain="yay -S"
# Install a package from a local file
alias yains="yay -U"
# Install packages as dependencies of another package
alias yainsd="yay -S --asdeps"
# Display information about a package in the local database
alias yaloc="yay -Qi"
# Search for packages in the local database
alias yalocs="yay -Qs"
# List installed packages including from AUR (tagged as "local")
alias yalst="yay -Qe"
# Force refresh of all package lists after updating mirrorlist
alias yamir="yay -Syy"
# Remove orphans using yaourt
alias yaorph="yay -Qtd"
# Remove packages, keeping its settings and dependencies
alias yare="yay -R"
# Remove packages, including its settings and unneeded dependencies
alias yarem="yay -Rns"
# Display information about a package in the repositories
alias yarep="yay -Si"
# Search for packages in the repositories
alias yareps="yay -Ss"
# Sync with repositories before upgrading packages
alias yaupg="yay -Syu"
# Same as yaupg, but without confirmation
alias yasu="yay -Syu --no-confirm"
alias yay_install_packages='yay -S'
alias yay_search_packages='yay -Ss'
alias yay_description_of_the_package='yay -Si'
alias yay_update_all_packages='yay -Syu'
alias yay_remove_package='yay -Rns'
alias yay_clean_unwanted_packages='yay -Yc'
alias mount_ESP="sudo mkdir -p /mnt/ESP && sudo mount -t msdos /dev/disk0s1 /mnt/ESP"
alias saferestart="leftwm-check | grep failed || leftwm-command SoftReload"
alias linux_kernel_log="sudo journalctl -p 3 -xb"
alias linux_kernel="journalctl -afn100"
alias linux_update="sudo pacman -Syyu"
alias linux_bundle="pacman -Qqe > pkglist.txt"
alias gnome_quit="gnome-session-quit --no-prompt"
alias linux_networks="sudo lshw -C network"
alias wmtest="awmtt start -C ~/.config/awesome/rc.lua -D 3 -S 1280x800"
alias wmreset="cp /etc/xdg/awesome/rc.lua ~/.config/awesome/rc.lua"
alias pacman_rm_corrupt_packages='sudo find /var/cache/pacman/pkg/ -iname "*.part" -delete'
alias openports='sudo lsof -i -P -n | grep LISTEN'
alias watchopenports='watch "sudo lsof -i -P -n | grep LISTEN"'
alias cronstatus="systemctl status cronie"
alias wminwm="Xephyr -br -ac -noreset -screen 1920x1200 :$@"
alias open="xdg-open"
fi