-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.zshrc
3916 lines (3160 loc) · 111 KB
/
.zshrc
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
# Profiling ZSH performance.
# zmodload zsh/zprof
# Dummy testing.
# alias gpmt="rmnm && rmv package.json rmv package-lock.json && npm init -y && rmv yarn.lock && rmv yarn-error.log && /Users/ahmadawais/.aCHANGEsdf/installs/nodejs/12.13.0/.npm/bin/gpm"
# Path to your oh-my-zsh installation.
export ZSH=/Users/$USER/.oh-my-zsh
# Set name of the theme to load.
ZSH_THEME="shades-of-purple"
#.# zsh-syntax-highlighting
# @link: http://github.com/zsh-users/zsh-syntax-highlighting
source ~/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red') # To have commands starting with `rm -rf` in red:
# Uncomment the following line to change how often to auto-update (in days).
export UPDATE_ZSH_DAYS=15
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
HIST_STAMPS="yyyy-mm-dd"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# plugins=(git git-extras extract npm bower brew composer wp-cli emoji z zsh-autosuggestions)
plugins=(git git-extras npm zsh-autosuggestions)
# PATH
export PATH="/usr/local/sbin:$PATH"
export VISUAL="code-insiders -w"
export EDITOR="code-insiders -w"
# Python from brew
# https://stackoverflow.com/a/51912712/950111
# export PATH=/usr/local/opt/python/libexec/bin:$PATH
export PATH="/opt/homebrew/opt/[email protected]/libexec/bin:$PATH"
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
## OLD
# export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/git:/usr/local/git/bin:$HOME/.wp-cli:~/bin:~/.composer/vendor/bin:/Users/$USER/Library/Python/2.7/bin"
## To use PHP7.1 on CLI, add this to .bash_profile
# export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"
# export PATH="/usr/local/opt/[email protected]/bin:$PATH"
# export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
eval "$(/opt/homebrew/bin/brew shellenv)"
# Homebrew completions.
# https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
# if type brew &>/dev/null; then
# FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
# autoload -Uz compinit
# compinit
# fi
# Oh My Zsh.
# Should inlcude after themes and plugins are set.
source $ZSH/oh-my-zsh.sh
# Aliases
alias zs="source ~/.zshrc"
alias zso="subl ~/.zshrc"
alias zco="code ~/.zshrc"
alias zci="code-insiders ~/.zshrc"
alias mco="code ~/.mackup.cfg"
# alias bco="code `bat --config-file`"
alias stgc="st ~/.gitconfig"
# Private exports are shy, they stay in Dropbox.
if [ -f ~/Dropbox/bin/.exports ]; then
source ~/Dropbox/bin/.exports
else
print "Hey ~/Dropbox/bin/.exports not found."
fi
alias rldexpo="source ~/Dropbox/bin/.exports"
# PrivateRC is shy, they stay in Dropbox.
if [ -f ~/Dropbox/bin/.privaterc ]; then
source ~/Dropbox/bin/.privaterc
else
print "Hey ~/Dropbox/bin/.privaterc not found."
fi
# Project paths.
if [ -f ~/Dropbox/bin/.paths ]; then
source ~/Dropbox/bin/.paths
else
print "Hey ~/Dropbox/bin/.paths not found."
fi
# Open Exports in VSCode.
alias expo="code-insiders --folder-uri $HOME/Dropbox/bin"
alias expi="code-insiders --folder-uri $HOME/Dropbox/bin"
# VSCode open folder
alias co="code ."
# VSCodeInsider open folder
alias ci="code-insiders ."
alias coi="code-insiders ."
alias cio="code-insiders ."
# Easier directory navigation.
alias ~="cd ~"
alias .="cd .."
alias ..="cd ../.."
alias ...="cd ../../.."
alias ....="cd ../../../.."
alias cd..="cd .." # Typo addressed.
# Type `-` only to go back to prev directory.
alias -- -="cd -"
# Projects.
# alias d="cd ~/Documents/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias sbx="cd ~/sbx"
# Git Blame Someone else (used for when my wife uses my laptop to code and forgets to switch profiles).
gbse() {
git blame-someone-else "$@"
}
# Same as above
gmb() {
git blame-someone-else "Maedah Batool <[email protected]>" "$@"
}
# gbsb() {
# git branch --set-upstream-to=origin/"$@" "$@"
# }
gbsu() {
if [[ -z "$@" ]]; then
# git branch --set-upstream-to=origin/main main
git branch --set-upstream-to=upstream/main main
else
# git branch --set-upstream-to=origin/"$@" "$@"
git branch --set-upstream-to=upstream/"$@" "$@"
fi
}
gstrk() {
cd /Users/$USER/Documents/web/Git/WPDev
python file.py "$*"
}
# Removes dotfile or dotfolder in the pwd e.g. .git
alias deldot="rm -rf .*"
# Removes everything in pwd
alias delpwd="rm -rf "$(pwd -P)"/*"
# trash is better
# alias t="sudo trash"
alias tpwd="t "$(pwd -P)"/*"
alias tdot="t .*"
alias ta="tdot ; tpwd"
# GIT
alias g="git"
alias gi="git init"
alias gco="git checkout"
alias gb="git branches"
alias gbd="git branch -D"
# Create new branch and checkout.
alias gbn='git checkout -b'
alias gfu='git fetch upstream && git pull upstream master'
alias gpu='git pull upstream master'
# Create a new branch on top of (by fetching) the latest origin/main branch.
gbno() {
git fetch origin
git checkout -b $@ origin/main
}
gbnu() {
git fetch --all
git checkout -b $@ upstream/main
}
# git merge branch
alias gm="git merge $* && git push"
# git clone realted
function gcl {
git clone "$1" && cd "$(basename "$1" .git)"
}
# show contributors by commits
alias gcontributors="git shortlog -sn"
# git commit count
alias gccount="git rev-list HEAD --count"
# Checkout to master
alias gcm="git checkout main"
# Create new branch and checkout.
alias gbn='git checkout -b'
# Remove local branch
gbdel() {
# Branch name present?
if [[ -z "$1" ]]; then
echo "\n🤔 Oops… you forgot to provide the branch name"
echo "👉 E.g. gbdel branch_name\n"
else
# Start deleteing.
echo "\n⏳ Deleting…\n"
git branch -D "$1" # Local delete.
git push origin --delete "$1" # Remote delete.
echo "\n✅ Git branch $1 was deleted from local and remote.\n"
fi
}
# Get a list of conflicts
alias conflicts='git diff --name-only --diff-filter=U'
grebase() {
git rebase -i @~"$*"
}
alias gref="git reflog"
alias gr="git r $@"
alias ghist="git log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short"
# All remotes
alias gremotes="git remotes"
# Add Origin
alias grao="git remote add origin"
# Remove remote origin
alias gdelro="git remote remove origin"
# Be careful that this will create an "alternate reality" for people who
# have already fetch/pulled/cloned from the remote repository. But in fact, it's quite simple:
gdelc() {
git r HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit
}
#delete remote branch
gbrdel() {
git push origin :"$1"
}
alias gsclear="git stash clear"
# alias gsc="git stash clear"
alias gsa="git stash apply"
alias gfo="git fetch origin"
alias grh="git reset --hard"
alias grhom="git reset --hard origin/master"
# r to head and remove all untracked files (including npm installs)
alias gitreverything='git clean -d -x -f; git reset --hard'
alias grhc='git clean -d -x -f; git reset --hard'
alias gcdf="git clean -d -f"
# alias gbrename="git branch -m"
alias gst="git status"
alias gss="git status -s"
alias gsb="git status -sb"
alias gad="git add ."
alias gc="git ci -m"
alias gcmall="git add . && git ci -m"
gcma() {
git add . && git ci -m "$*"
}
alias gp="git push"
alias gpp="git push -u"
alias gpf="git push --force"
alias gpfs="git push --force-with-lease"
alias gpt="git push --tags"
# delete git and re-inialize git
alias gdelinit="trash .git && git init"
# git add commit and then fix an issue on github
# usage: gifix 5
# Where 5 is the issue number
gifix() {
issue=$*
git add . && git ci -m "ISSUE: Fixes #$(echo -e "$issue")" && gp
}
alias gdel="rm -rf .git"
alias gpsuom="git push --set-upstream origin master"
alias gpsuo="git push --set-upstream origin"
alias gpdt="git push --delete origin"
# Amend the last commit message.
# Push the changes to remote by force.
# USAGE: gamend "Your New Commit Msg"
gamend() {
git commit --amend -m "$@"
git push --force-with-lease
}
# Git fethc & Pull
alias gf="git fetch"
alias gpl="git pull"
alias gfp="git fetch && git pull && git submodule update"
# Open git config file
alias gconfig="git config --global --edit"
# Git Tags
# list all tags
alias gtag="git tag"
alias gtagd="git tag -d $*"
alias gtagdp="git push origin :refs/tags/$*"
gtagit() {
git tag $@
git push origin --tags
}
wprlz() {
grlz $@
gtagit $@
}
gtagdel() {
the_tag=$*
echo "${rb}${wf}1. Deleting the tag...${r}"
git tag -d $the_tag
echo "${rb}${wf}2. Deleting the tag at remote origin...${r}"
git push origin :refs/tags/$the_tag
echo "${gb}${bf}Completed!...${r}"
}
# Type `git open` to open the GitHub page or website for a repository.
# npm install -g git-open
alias gio="git open"
# git diff last commit
alias gd1="git diff HEAD^"
# git diff word diffing
alias gdw="git diff --word-diff"
# Git Diff so fancy
alias gdsf="git diff --color | diff-so-fancy"
# Check the changes in last Git Pull/Fetch
# Usage: gpfchanges branch_name
alias gfpchanges="git diff --stat $1@{1}$1"
# Git archive the current directory and ignore everything in .gitignore file.
# Usage: garc zipname
alias garc="git archive -o $1.zip HEAD"
# Fun commit messages
alias yolo="git commit -am '$(curl -s http://whatthecommit.com/index.txt)'"
alias yoloo="git commit -am '$(curl -s http://whatthecommit.com/index.txt)' && git push origin master --force"
# Open the pwd in the finder
alias o="open ."
# SVN related
# https://wordpress.org/plugins/about/svn/
alias s="svn"
alias sst="svn st"
alias sci="svn ci -m $*"
alias saddall="svn add --force ."
# SVN Add the assets.
alias sassets="saddall && svn ci -m 'Adding the assets...'"
# Add SVN tag
# Usage: stag tags/1.0
alias stag="svn cp trunk"
# SVN revert deletes added folders which are not commited but only added
alias sr="svn revert $@ --depth infinity"
# SVN revert everything like r hard
alias sra="svn st | grep '!' | sed 's/!M \(.*\)$/"\1"/' | xargs svn revert --depth infinity"
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en1"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
alias myip="curl ipecho.net/plain ; echo"
# All the dig info
alias dig="dig +nocmd any +multiline +noall +answer"
alias l="exa --long --all --header --git-ignore --group-directories-first --git --ignore-glob=\".git|node_modules\" --sort=\"ext\""
# List ALL files (colorized() in long format, show permissions in octal
alias la="ls -l | awk '
{
k=0;
for (i=0;i<=8;i++)
k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));
if (k)
printf(\"%0o \",k);
printf(\" %9s %3s %2s %5s %6s %s %s %s\n\", \$3, \$6, \$7, \$8, \$5, \$9,\$10, \$11);
}'"
# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
# List only dot files
alias lsdot="ls -ld .??*"
# Enable aliases to be sudo’ed
# alias sudo='sudo '
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# Copy backup
# http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/
alias copybuildit="rsync -avz --exclude 'node_modules' --exclude 'build' ./* ./build"
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
# the `.git` directory, listing directories first. The output gets piped into
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
tre() {
tree -a --ignore '.git|node_modules|bower_components|.DS_Store' "$@"
}
alias t="tree -a --ignore '.git|node_modules|bower_components|.DS_Store' -l 3"
# cd Shortcuts
alias des="cd Desktop"
# Empty the Trash on all mounted volumes and the main HDD. then clear the useless sleepimage
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; rm -rfv ~/.Trash; sudo rm /private/var/vm/sleepimage"
alias et="sudo rm -rfv /Volumes/*/.Trashes; rm -rfv ~/.Trash; sudo rm /private/var/vm/sleepimage"
# yes I occasionally 127.0.0.1 twitter.com ;)
alias hosts='sudo code /etc/hosts'
alias cask='brew cask' # i <3 u cask
# alias where=which # sometimes i forget
alias brwe=brew #typos
# brew install speedtest-cli
alias sts='speedtest-cli --share'
alias stss='speedtest-cli --simple --share'
# Update installed Ruby gems, Homebrew, npm, and their installed packages
alias brew_update="brew -v update; brew upgrade --force-bottle --cleanup; brew cleanup; brew cask cleanup; brew prune; brew doctor; npm-check -g -u"
alias update_brew_npm_gem='brew_update; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update --no-document'
# Sublime's subl.
# Install subl as st by running the following
# ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/st
# Relaod the terminal.
# Now Open a file with → st filename.ext
# Open a folder in Sublime.
alias stt="st ."
# Get week number
alias week='date +%V'
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# Recursively delete all `.DS_Store` files in the pwd.
alias rmds="find . -type f -name '*.DS_Store' -ls -delete"
alias rmlockfiles="find . -type f -name 'package-lock.json' -ls -delete"
# Recursively delete all `.nfo` files in the pwd.
alias rmnfo="find . -type f -name '*.nfo' -ls -delete"
# Del all node modules from current dir and inside there in more dirs recursively.
alias delnm="find . -name "node_modules" -type d -prune -exec rm -rf '{}' +"
alias nmrmv="find . -name "node_modules" -type d -prune -exec rm -rf '{}' +"
alias rmnm="find . -name "node_modules" -type d -prune -exec rm -rf '{}' +"
alias nmrm="find . -name "node_modules" -type d -prune -exec rm -rf '{}' +"
# Show/Hide hidden files/directories in macOS Finder.
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# Show/Hide all desktop icons (useful when presenting or recording).
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Hide a directory or file.
# @usage: hidden fileOrDirName
hidden() {
chflags hidden "$@"
}
# Merge PDF files
# Usage: `mergepdf -o output.pdf input{1,2,3}.pdf`
alias mergepdf='/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py'
# Decrypt a password-protected PDF
# Needs brew install qpdf
# https://superuser.com/a/1735907
decryptpdf() {
echo "Enter password followed by <enter> followed by <ctrl-D>"
qpdf --decrypt --password-file=- --replace-input "${1}"
}
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 7'"
# Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
alias killchrome="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
# Lock the screen (when going AFK)
alias lock="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
# Reload the shell (i.e. invoke as a login shell).
alias reload="exec $SHELL -l"
alias rf="source ~/.zshrc"
# Typos addressed.
alias relaod="reload"
alias reld="reload"
alias rld="reload"
alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | printf '=> Public key copied to clipboard.\n'"
alias vup="vagrant up && vagrant provision && vagrant ssh"
alias vp="vagrant provision"
alias vs='sites && vagrant ssh'
alias vag="vagrant"
alias bell='echo "\a"'
alias cdate='date "+%d—%m—%Y"'
#tree structures
alias ll1="tree --dirsfirst -ChFL 1"
alias ll2="tree --dirsfirst -ChFL 2"
alias ll3="tree --dirsfirst -ChFL 3"
alias ll4="tree --dirsfirst -ChFupDaL 1"
alias ll5="tree --dirsfirst -ChFupDaL 2"
alias ll6="tree --dirsfirst -ChFupDaL 3"
#show hidden files and everything
alias lla="ll -a"
# Another useful flag we can use with ls is -S, which will sort the results of ls by file size, instead of the default sorting by name.
alias lls="ls -lhS"
alias pc='phpcs --standard="WordPress" $@'
alias pcf='phpcbf --standard="WordPress" $@'
alias pcfall='find . | grep .php | xargs phpcbf --standard="WordPress"'
alias clive="caffeinate -t $*"
alias nosleep="caffeinate -t 50000"
alias nsl="caffeinate -t 50000"
# NPM Quickes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# npm
# alias n='npm'
# alias nx='/usr/local/bin/n'
# alias n='/usr/local/bin/n'
# npm aliases
alias ni="npm install"
alias nrm="npm rm"
alias nd="npm run dev"
alias nl="npm link"
alias nu="npm unlink"
alias s="npm start"
alias b="npm run build"
alias d="npm run dev"
alias ni='npm install'
alias nig='npm install -g'
alias nrmg='npm uninstall -g'
# npm-check to update npm packages https://www.npmjs.com/package/npm-check
alias ncupg='npm-check -g -u'
alias ncup='npm-check -u'
# pnpm aliases
alias p="pnpm"
alias pi="pnpm install"
alias pr="pnpm"
alias prm="pnpm rm"
alias pd="pnpm dev"
alias pl="pnpm link"
alias pu="pnpm unlink"
alias pb="pnpm run build"
alias pd="pnpm run dev"
# alias ps="pnpm start" # Conflict with ps.
# Fix Issues --Hard
nf() {
rm -rf ./node_modules
npm install
}
# Fix Issues
ncc() {
npm clear cache
npm clean cache
}
# {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ WP CLI }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
# WP DesktopServer Setup ready
# ---Updates the Core and 2015 theme
# ---Deletes 2013, 2014 and Aksimet
# Usage
# 1. First argument is the url E.g. aa.dev
# 2. Second argument is the Site Title E.g. AA
# Example: wpdsready local.dev Local
wpdsready() {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}WP: Core Installing...${r}"
wp core install --url=$1 --title=$2 --admin_user=root --admin_password=root [email protected]
echo "${wb}${bf}WP: twentyfifteen Update...${r}"
wp theme update twentyfifteen
wp theme activate twentyfifteen
echo "${rb}${bf}WP: Removing twentythirteen...${r}"
wp theme delete twentythirteen
echo "${rb}${bf}WP: Removing twentyfourteen...${r}"
wp theme delete twentyfourteen
echo "${rb}${bf}WP: Removing twentysixteen...${r}"
wp theme delete twentysixteen
echo "${rb}${bf}WP: Removing twentyseventeen...${r}"
wp theme delete twentyseventeen
echo "${rb}${bf}WP: Removing akismet...${r}"
wp plugin delete akismet
echo "${rb}${bf}WP: Removing Hello Dolly...${r}"
wp plugin delete hello
echo "${rb}${bf}WP: Setting permalinks to postname...${r}"
wp option update permalink_structure '/%postname%'
echo "${wb}${bf}WP: Core Updating...${r}"
wp core update
echo "${gb}${bf}WP: DS Setup Ready. DONE!${r}"
echo "${wf}———————————————————${r}"
}
alias wpppn="wp option update permalink_structure '/%postname%'"
# Install WPTest.io
wptest() {
wp plugin install wordpress-importer --activate
curl -OL https://raw.githubusercontent.com/manovotny/wptest/master/wptest.xml
wp import wptest.xml --authors=create
rm wptest.xml
}
# WP Plugin: Install & Acticate
# Usage: wpp plugin-slug
alias wpp="wp plugin install $* --activate"
# WP Theme: Install
# Usage: wpt plugin-slug
alias wpt="wp theme install $* --activate"
# WP Theme: Activate
# Usage: wpta plugin-slug
alias wpt="wp theme activate $*"
# Activate all WP Plugins
alias wppaall="wp plugin activate --all"
# Launch WP with logged in as root admin
# @link https://aaemnnost.tv/2016/08/26/going-plaidinum/
#
# Install dependencies:
# wp package install aaemnnosttv/wp-cli-login-command
# On a WP install run wpli.
#
alias wplr="wp login create root --launch"
alias wpli="wp login install --activate --yes"
# Install WP Log Viewer.
alias wplv="wpp wp-log-viewer"
# Trash all posts in a cpT replace the post-type.
# alias wpdb="wp post delete $(wp post list --post_type='vr_booking' --format=ids)"
# alias wpdtall="wp post delete $(wp post list --post_status=trash --format=ids)"
# One Click Demo Import and friends.
alias ocdis="wpp one-click-demo-import && wpp widget-importer-exporter && wpp customizer-export-import"
# Dev Setup.
alias wpds="wpp query-monitor && wpp debug-bar && wpp debug-meta-data && wpp wp-log-viewer && wpp wp-reset"
# {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ WP CLI END }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
# NVM install
# export NVM_DIR="$HOME/.nvm"
# . "/usr/local/opt/nvm/nvm.sh"
# export NVM_DIR=~/.nvm
# source $(brew --prefix nvm)/nvm.sh
# alias load_nvm=". /usr/local/opt/nvm/nvm.sh"
# nvm now.
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm.
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# asdf
# source $HOME/.asdf/asdf.sh
# source $HOME/.asdf/completions/asdf.bash
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# load_nvm() {
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm.
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# }
# alias node='unalias node ; unalias npm ; load_nvm ; nvm use default ; node $@'
# alias npm='unalias node ; unalias npm ; load_nvm ; nvm use default ; npm $@'
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# 10 second wait if you do something that will delete everything. I wish I'd had this before...
# setopt RM_STAR_WAIT
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
# I don't use z.
# include z rupa
# . ~/z.sh
####.#### ———————————————————————————————————————————— COLORS ———————————————————————————————————————————— ####.####
# colors from tput
# http://stackoverflow.com/a/20983251/950111
# Num Colour #define R G B
# 0 black COLOR_BLACK 0,0,0
# 1 red COLOR_RED 1,0,0
# 2 green COLOR_GREEN 0,1,0
# 3 yellow COLOR_YELLOW 1,1,0
# 4 blue COLOR_BLUE 0,0,1
# 5 magenta COLOR_MAGENTA 1,0,1
# 6 cyan COLOR_CYAN 0,1,1
# 7 white COLOR_WHITE 1,1,1
#
# tput setab [1-7] # Set the background colour using ANSI escape
# tput setaf [1-7] # Set the foreground colour using ANSI escape
# tput sgr0 # Reset text format to the terminal's default
# tput bel # Play a bell
#
# Usage:
# red=`tput setaf 1`
# green=`tput setaf 2`
# r=`tput sgr0`
# echo "${rb}red text ${green}green text${r}"
bb=$(tput setab 0) #set background black
bf=$(tput setaf 0) #set foreground black
gb=$(tput setab 2) # set background green
gf=$(tput setaf 2) # set foreground green
yb=$(tput setab 3) # set background yellow
yf=$(tput setaf 3) # set foreground yellow
blb=$(tput setab 4) # set background blue
blf=$(tput setaf 4) # set foreground blue
mb=$(tput setab 5) # set background magenta
mf=$(tput setaf 5) # set foreground magenta
rb=$(tput setab 1) # set background red
rf=$(tput setaf 1) # set foreground red
wb=$(tput setab 7) # set background white
wf=$(tput setaf 7) # set foreground white
r=$(tput sgr0) # r to defaults
# Create a new directory and cd into it.
# USAGE: mkd new-dir
mkd() {
mkdir -p "$@" && cd "$@"
}
# git checkout branch
function gcb {
git fetch
git checkout -b $@ origin/$@
}
# Remove .DS_Store files from a Git repository?
alias grmds="find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch && addgitignore"
# checks if pwd is empty or not
dirempty() {
# DIR=pwd
# look for empty dir
if [ "$(ls -A $(pwd -P))" ]; then
echo "$(pwd -P) is NOT Empty"
else
echo "$(pwd -P) is Empty"
fi
# rest of the logic
}
# Create a data URL from a file
dataurl() {
local mimeType=$(file -b --mime-type "$1")
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8"
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
}
# Create a git.io short URL
gitio() {
if [ -z "${1}" -o -z "${2}" ]; then
echo "Usage: \`gitio slug url\`"
return 1
fi
curl -i https://git.io/ -F "url=${2}" -F "code=${1}"
}
#
# Git Clone repo inside current director even if it is not empty.
#
# git clone repo . i.e. inside current directory
# usage: gclhere Repo URL
# usage: gclhere https://github.com/user/repo
# Equal to rm -rf .* && rm -rf "$(pwd -P)"/* && git clone "$*" .
#
gclhere() {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}0. Initializing...${r}"
#if not empty
if [ "$(ls -A $(pwd -P))" ]; then
echo "${rb}${bf}1. PWD is not empty, let's delete it...${r}"
# PWD variable
aa_pwd=$PWD
# go back
cd ..
# trash the old PWD where git repo needs to be cloned
sudo trash $aa_pwd
# recreate the old PWD and cd in it
mkdir $aa_pwd && cd $aa_pwd
echo "${rb}${bf}2. PWD deleted and recreated...${r}"
echo "${blb}${wf}3. Starting git repo clone...${r}"
git clone --recursive "$*" .
echo "${gb}${bf}4. Git repo cloned. DONE!${r}"
# if empty
else
echo "${blb}${wf}1. Directory is empty. Cloning the repo...${r}"
echo "${blb}${wf}2. Starting git repo clone...${r}"
git clone --recursive "$*" .
echo "${gb}${bf}3. Git repo cloned! DONE!${r}"
fi
echo "${wf}———————————————————${r}"
}
alias gclh="gclhere"
emptypwd() {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}0. Initializing...${r}"
#if not empty
if [ "$(ls -A $(pwd -P))" ]; then
echo "${rb}${bf}1. PWD is not empty, let's delete it...${r}"
# PWD variable
aa_pwd=$PWD
# go back
cd ..
# trash the old PWD where git repo needs to be cloned
trash $aa_pwd
# recreate the old PWD and cd in it
mkdir $aa_pwd && cd $aa_pwd
echo "${gb}${bf}2. PWD deleted and recreated!!!${r}"
# if empty
else
echo "${gb}${bf}1. Directory is already empty!!!${r}"
fi
echo "${wf}———————————————————${r}"
}
#
# Git Checkout a Pull Request locally.
#
# Usage: gfpr 8
#
# Where 8 is the number of pull request (can be found right after the PR's title).
#
gfpr() {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}0. Fetching the pull request...${r}"
git fetch origin pull/"${1}"/head:PR#"${1}"
echo "${wb}${bf}1. PR fetched creating a branch...${r}"
git checkout PR#"${1}"
echo "${wb}${bf}2. Checking out to a new PR branch...${r}"
echo "✅ — ${gb}${bf}3. PR Branch Created!${r}"
echo "${wf}———————————————————${r}"
}
function gpr {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}0. Fetching the pull request...${r}"
git fetch origin pull/"${1}"/head:PR#"${1}"
echo "${wb}${bf}1. PR fetched creating a branch...${r}"
git checkout PR#"${1}"
echo "${wb}${bf}2. Checking out to a new PR branch...${r}"
echo "✅ — ${gb}${bf}3. PR Branch Created!${r}"
echo "${wf}———————————————————${r}"
}
gfupr() {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}0. Fetching the pull request...${r}"
git fetch upstream pull/"${1}"/head:PR#"${1}"
echo "${wb}${bf}1. PR fetched creating a branch...${r}"
git checkout PR#"${1}"
echo "${wb}${bf}2. Checking out to a new PR branch...${r}"
echo "✅ — ${gb}${bf}3. PR Branch Created!${r}"
echo "${wf}———————————————————${r}"
}
#
# Git Fetch a Pull Request locally to current branch.
#
# Usage: gfpr 8
#
# Where 8 is the number of pull request (can be found right after the PR's title).
#
gfpronly() {
echo "${wf}———————————————————${r}"
echo "${wb}${bf}0. Fetching the pull request...${r}"