-
Notifications
You must be signed in to change notification settings - Fork 5
/
.aliases
229 lines (175 loc) · 8.95 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
#!/usr/bin/env zsh
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
alias cd="j"
# Shortcuts
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias doc="cd ~/Documents"
alias dotfiles="cd ~/.dotfiles"
alias devzone="cd $DEV_ZONE"
alias h="history"
alias where=which
alias clearhistory="cat /dev/null > ~/.zsh_history && history -p && exit"
alias du='dua -f binary'
alias dig='dog --time'
alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc'
alias t='tail -f'
alias help='man'
alias p='ps -f'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ff='find . -type f -name'
# https://eza.rocks/
alias tree='ll --tree'
alias ls='command eza --color=always --no-git --no-filesize --octal-permissions --icons=always --header --grid --group-directories-first --group --sort=type'
alias ll='command eza --color=always --octal-permissions --icons=always --no-git --no-filesize --header --group-directories-first --group --sort=type --oneline --long --all'
alias lsa='command eza --oneline --color=always --octal-permissions --icons=always --header --group-directories-first --group --sort=type --oneline --long --all --extended --git --git-repos --total-size'
alias cat="command bat --theme=DarkNeon --style=header-filename --pager=never"
# cask alias
alias cask='function _nmrcask(){ brew "$@" --cask};_nmrcask;'
# cp
alias cpv='rsync -Paz --progress'
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Get week number
alias week='date +%V'
# Pipe my public key to my clipboard.
alias pubkey="more ~/.ssh/$SSH_KEY_FILE_NAME.pub | pbcopy | echo '=> Public key copied to pasteboard.'"
# Pipe my private key to my clipboard.
alias prikey="more ~/.ssh/$SSH_KEY_FILE_NAME | pbcopy | echo '=> Private key copied to pasteboard.'"
# copy working directory
alias cwd='pwd | tr -d "\r\n" | pbcopy'
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
# 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'"
# Trim new lines and copy to clipboard
alias c="tr -d '\n' | pbcopy"
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# Canonical hex dump; some systems have this symlinked
command -v hd >/dev/null || alias hd="hexdump -C"
# OS X has no `md5sum`, so use `md5` as a fallback
command -v md5sum >/dev/null || alias md5sum="md5"
# OS X has no `sha1sum`, so use `shasum` as a fallback
command -v sha1sum >/dev/null || alias sha1sum="shasum"
# update Homebrew, npm, mise, zi-sheel, and their installed packages
alias rmbrewlock="rm -rf $(brew --prefix)/var/homebrew/locks"
alias update='rm -rf $(brew --prefix)/var/homebrew/locks && brew update --verbose && brew update --cask && brew upgrade && brew upgrade --force --cask --greedy && brew autoremove && brew cleanup -s --prune=all && zi self-update && zi update && mise plugins upgrade && mise upgrade --interactive && npm-upgrade -g'
# Get macOS Software Updates
alias macupdate='sudo softwareupdate --list && sudo softwareupdate --install -all'
# Flush Directory Service cache
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
# Clean up LaunchServices to remove duplicates in the “Open With” menu
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# Show/hide hidden files in 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"
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# Disable Spotlight
alias spotoff="sudo mdutil -a -i off"
# Enable Spotlight
alias spoton="sudo mdutil -a -i on"
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
# Ring the terminal bell, and put a badge on Terminal.app’s Dock icon
# (useful when executing time-consuming commands)
alias badge="tput bel"
# Intuitive map function
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias map="xargs -n1"
# 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 chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
# Brave Browser
alias bravekill="ps ux | grep '[B]rave Browser Helper (Renderer)' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
# Lock the screen (when going AFK)
alias afk="/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"
# View HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# 1. NETWORKING
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets
alias ipInfo0='ipconfig getpacket eth0' # ipInfo0: Get info on connections for en0
alias ipInfo1='ipconfig getpacket eth1' # ipInfo1: Get info on connections for en1
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs
# IP addresses
alias pubip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="sudo ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
alias ips="sudo ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Clean up LaunchServices to remove duplicates in the “Open With” menu
alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# view HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# one of @janmoesen’s ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "$method"="lwp-request -m '$method'"
done
# vagrant network list
alias vbox-nets="vboxmanage list bridgedifs"
# git commitzen aliases
alias gcz='git-cz'
alias gld='git pull origin develop'
# set vim alias
alias vi=nvim
alias vim=nvim
# docker terminal ui
alias lzd='lazydocker'
# git terminal ui
alias lzg='lazygit'
# Scala Alias
alias cs='coursier'
# Scala Alias
alias hostses='sudo txeh'
# Weather
alias weather='function _weather() { http --body https://wttr.in/${1:-Dhaka}; }; _weather'
# Set JAVA_HOME
alias setjhome='source $HOME/.asdf/plugins/java/set-java-home.zsh'
# # Python alias
# alias python=/usr/bin/python3
# alias pip=/usr/local/bin/pip3
# Terraform aliases
alias tf='terraform'
alias tfa='terraform apply'
alias tfc='terraform console'
alias tfd='terraform destroy'
alias tff='terraform fmt'
alias tfi='terraform init'
alias tfo='terraform output'
alias tfp='terraform plan'
alias tfv='terraform validate'
alias tfs='terraform state'
alias tft='terraform test'
alias tfsh='terraform show'
# zellij alias
alias zjclear='zellij delete-all-sessions --force --yes'
# sshs: https://github.com/quantumsheep/sshs
alias sshs='sshs -e --sort'