-
Notifications
You must be signed in to change notification settings - Fork 2
/
4-aliases.rc
220 lines (178 loc) · 8.72 KB
/
4-aliases.rc
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
# shellcheck disable=SC2148 disable=SC1090 shell=bash
#TODO: cleanup this, move stuff out of Dropbox\ Import
THIS_DIRECTORY="/Users/samm/Library/Mobile Documents/com~apple~CloudDocs/Dropbox Import/dotfiles/shell_config"
### Aliases ###
# Directory Jumps
alias d="cd ~/Downloads && ls -ltarh"
alias icloud_drive="cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/"
# IDE Projects
#shellcheck disable=SC2139
alias zshconfig="code '${THIS_DIRECTORY}'"
alias zzshconfig="zed '${THIS_DIRECTORY}'"
# shellcheck disable=SC2139
alias wezedit="code '${HOME}'/.config/wezterm/wezterm.lua"
#shellcheck disable=SC2139
alias zshconfigd="cd '${THIS_DIRECTORY}'"
alias app_store_upgrade_mmas="mas upgrade"
alias go_update_all="gup update"
alias pa="pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
# Second homebrew install with x86 arch
alias brew86="arch -x86_64 /usr/local/homebrew/bin/brew"
# Git
# alias gbd="git branch -d" Moved to functions
#alias gitrb='for branch in $(git branch -r --merged | grep -v HEAD); do echo -e $(git show --format="%ci %cr %an" "$branch" | head -n 1) \\t$branch; done | sort -r'
alias amend="git commit --amend --no-edit"
alias bfg="java -jar ~/bin/bfg.jar"
alias ch="commit-hotfix"
alias cj="commit-jira"
alias commit="git commit -m"
alias git-cleanup-repack="bfg"
alias git-delete-local-branches="git fetch --all --prune"
alias git-delete-remote-branch="git push origin --delete"
alias git-my-recent-branches="git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf(" %12s:\t%s\n", substr($2, 1, length($2) - 1), $1)}'"
alias git-remove-untracked-branches="git fetch -p; git branch --merged main | egrep -v '^\s*\*?\s*main$' | xargs -r git branch -d" #and re-run with -D if required
alias gitamendrebase="GIT_SEQUENCE_EDITOR=\"sed -i -re 's/^pick /e /'\"; git rebase -i"
alias gitclean="git fetch -p; git remote prune origin; git repack -a -d -f --max-pack-size=10g --depth=500 --window=250; git gc --aggressive"
alias gitday="git diff HEAD 'HEAD@{1 day ago}'"
alias gitdiff="git diff --color-words --color=always"
alias githist="git log --graph --pretty=oneline --abbrev-commit"
alias github-runs="github_actions_watcher"
alias gitlast="git add .;git commit --amend -C HEAD ; git push"
alias gitmonth="git diff HEAD 'HEAD@{1 month ago}'"
alias gitupdateallrepos="find . -name .git -type d | xargs -n1 -P4 -I% git --git-dir=% --work-tree=%/.. fetch --all --recurse-submodules"
alias gitweek="git diff HEAD 'HEAD@{1 week ago}'"
alias gitwip="git add .; git commit -n -m 'minor updates'; git push"
alias hotfix-checkout="checkout-hotfix"
alias hotfix-commit="commit-hotfix"
alias hotfix="checkout-hotfix"
alias L="ls -ltarh"
alias j="checkout-jira"
alias jira-checkout="checkout-jira"
alias jira-commit="commit-jira"
alias jira="checkout-jira"
alias main="git checkout main && git pull"
alias minor="git commit -m 'chore: minor tweaks [skip ci]"
### Short git aliases
alias add="git add ."
alias c="git commit -m"
alias h="hugo serve --disableFastRender --buildDrafts"
alias m="git checkout main"
alias p="git pull"
alias P="git push"
# GNU tools
alias sed="gsed"
# Find commands I type often so I can alias them
alias typeless='history n 20000 | sed "s/.* //" | sort | uniq -c | sort -g | tail -n 100'
# alias jpgcompress='echo convert INPUTFILE -sampling-factor 4:2:0 -strip -interlace JPEG -colorspace sRGB OUTPUTFILE'
# NPM / Yarn
# Check for unused packages
alias npm-check-unused="npx npm-check"
# Misc
alias farsync='rsync -xrhm --numeric-ids -e "ssh -T -c [email protected] -o Compression=no" -x --partial --progress' #TODO: fix bug where this overwrites file name
alias arcfarsync="rsync -rhm --numeric-ids -e 'ssh -T -c arcfour -o Compression=no -x' --partial --progress"
alias tree="tree -ChF"
alias mtr="sudo mtr"
alias iftop="sudo iftop -i en0"
alias ls='gls --color=auto -AHhF --group-directories-first'
alias updatedb='sudo /usr/libexec/locate.updatedb'
alias netwatch='lsof -i'
alias flushdns='sudo discoveryutil udnsflushcaches'
alias httpserver='sudo python3 -m http.server 80'
alias cc='colorize.py'
alias rmid="ssh-keygen -R"
# alias aria="aria2c -s 5 -j 5 -x 5 -c --enable-http-pipelining=true --http-accept-gzip=true --max-connection-per-server=10"
# alias a=aria
alias dmesg="dmesg -LT"
alias cpuinfo="sysctl -n machdep.cpu.brand_string"
# alias psql="/Applications/Postgres.app/Contents/Versions/latest/bin/psql"
alias fastmail_you_there_bro="openssl s_client -connect imap.fastmail.com:993 -crlf"
alias zmv='noglob zmv -W'
alias mc='yazi'
# MacOS shortcuts
# alias delete-all-local-snapshots='for d in $(tmutil listlocalsnapshotdates | grep -v "Snapshot dates for all disks"); do sudo tmutil deletelocalsnapshots $d; done'
alias clear-download-history="sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
alias screenshots-jpg='defaults write com.apple.screencapture type JPG'
alias screenshots-png='defaults write com.apple.screencapture type PNG'
# Kubes
alias kubes-busybox='kubectl run -i --tty loader --image=busybox /bin/sh'
alias k='kubectl'
# VSC
alias code='/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code'
# Merge two files with diff
alias merge='diff --line-format %L'
# Terraform
alias t='terraform'
alias tf='terraform'
alias tfn='terraform'
# DNS benchmarking using https://github.com/redsift/dnstrace
alias dnsbenchmark='dnstrace -n 10 -c 10 --server 192.168.0.1 --recurse microsoft.com'
# Docker
# podman machine init --cpus=3 --disk-size=30 --memory=3192 podman-machine-default
# colima start --cpu 3 --memory 3 --disk 30 --mount $HOME/.vault-tokens:w
# ln -s /usr/local/bin/colima /usr/local/bin/docker
# alias docker='colima'
alias youtube-dl='yt-dlp'
alias nvm='echo I think you meant FNM'
# node / typescript
# update all packages in package.json except @types/node
alias ncu='ncu -u \!@types/node --deep'
# nice JSON graphing / visualisation tool
alias json-graph='colima start && docker run -p 8888:8080 jsonvisio && open http://localhost:8888/editor'
# Backblaze
alias backblaze_edit='code /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml'
alias scripts='cd ~/git/scripts'
alias nzb="cd ~/git/sammcj/nzb-docker"
alias nzbdocker="open vscode://vscode-remote/ssh-remote+nas/root/git/nzb-docker/.vscode/nas-docker.code-workspace"
### Suffix Aliases ###
# VSCode
alias -s {ts,json,yaml,css,yml}=code
# Firefox
alias -s html=/Applications/Firefox.app
# VLC
alias -s {mkv,mp4,m4v,avi,mpg,mpeg}=vlc
# Preview
alias -s {jpg,jpeg,png,gif,bmp,ico,svg,webp}=open
# Glow for Markdown
alias -s md=glow
# Networking
alias ip6="curl -s 6.ipquail.com/ip"
alias ip4="curl -s 4.ipquail.com/ip"
alias ptr6="curl -s 6.ipquail.com/ptr"
alias ptr4="curl -s 4.ipquail.com/ptr"
# Find files modified today
alias modified-today="mdfind 'kMDItemFSContentChangeDate>\$time.today'"
# If running on macOS replace lsusb with ioreg -p IOUSB -l -w 0
if [[ "$OSTYPE" == "darwin"* ]]; then
alias lsusb='ioreg -p IOUSB -l -w 0'
fi
# 3D Printing
alias rockpi='ssh root@rockpi'
alias cura='open -a /Applications/UltiMaker Cura.app'
alias cura-backup='cp -r ~/Library/Application\ Support/cura/*.zip ~/Library/Mobile\ Documents/com~apple~CloudDocs/Backups/3dprinting/cura/'
alias backup-models="rsync -avr --partial '/Users/samm/Library/Mobile Documents/com~apple~CloudDocs/3D Printing/Models' root@nas:/mnt/raid/3dprinting/"
alias backup-models-delete="rsync -avr --partial '/Users/samm/Library/Mobile Documents/com~apple~CloudDocs/3D Printing/Models' root@nas:/mnt/raid/3dprinting/ --delete"
alias creality='/Users/samm/git/sammcj/ender-configs/creality-sonic-pad/login.exp'
alias ender='cd ~/git/sammcj/ender-configs/ && code .'
# pip install git+https://github.com/ChristophSchranz/Tweaker-3.git
alias rotate='tweaker3 -vb -x -i'
alias rotate_min_supports='tweaker3 -vb -x -min sur -i'
alias obsidian='cd /Users/samm/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Main && ls -ltarh'
# ML / Github Copilot
alias copilot="gh copilot suggest -t shell"
alias copilot-explain="gh copilot explain"
alias '??'='copilot'
alias wtf='copilot'
alias l="OLLAMA_HOST=http://localhost:11434 gollama -l"
alias i="ingest"
alias code2prompt="ingest"
alias ln="gollama -l"
alias gl="gollama"
alias ol="mods"
alias idf='. $HOME/git/esp-idf/export.sh'
alias o='tlm explain'
alias hf="hfdownloader -c 10 -t \$HUGGINGFACE_TOKEN -j"
alias imagesearch="sisi search"
# uv
alias venv='uv venv ; source .venv/bin/activate'
### AWS ###
alias aws-rds-list-instances="aws rds describe-db-instances --region ap-southeast-2 --query \"DBInstances[].{Instance: DBInstanceIdentifier, Class: DBInstanceClass, Endpoint: Endpoint.Address, Status: DBInstanceStatus}\" --output text | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g'"