-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathaliases
More file actions
412 lines (342 loc) · 12.1 KB
/
aliases
File metadata and controls
412 lines (342 loc) · 12.1 KB
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
#!/bin/zsh
# vim: ft=zsh
# remove zinit alias - so I can use zoxide's zi (z interactive)
unalias zi
# Unix
# short for ls
alias l="ls"
# just like l but a single column
alias l1="l -1"
# full long list with permissions, size, ownership etc
alias ll="l -l --date=relative --blocks name,size,date,user"
# just like ll but with git status
alias llg="ll --git"
# sorts the list by created date asc, so that the latest file is closer to the
# prompt
alias llc="ll --sort=created"
# use lsd instead of system ls
alias ls="lsd -ahF --group-directories-first"
alias ln="ln -v"
alias mkdir="mkdir -p"
alias rm='trash'
alias rmf='trash'
alias rmrf='trash'
alias less='less -r'
alias top="sudo htop" # alias top and fix high sierra bug
alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"
alias tf='terraform'
alias tfa='terraform apply'
alias tfd='terraform destroy'
# select a tv channel and return the result
# can be composed like `cd $(tt)` and then select git-repos, then after
# selecting a repo it will cd into it's directory
alias tt='tv channels'
# kubernetes context switcher (like kubectx)
kctx() {
if [[ "$1" == "-u" ]]; then
kubectl config unset current-context
else
tv kctx --inline "$@"
fi
}
# kubernetes namespace switcher (like kubens)
alias kns='tv kns --inline'
# AI tooling
alias oc='opencode --port'
alias ocr='opencode run'
alias cld='claude'
# opencode in docker
alias ocd='docker run -it --rm -v "$(pwd):/workspace" -v "$HOME/.config/opencode:/root/.config/opencode" -v "$HOME/.local/share/opencode:/root/.local/share/opencode" -w /workspace ghcr.io/anomalyco/opencode'
# check internet connection
alias chkint='pingf kagi.com'
# just like l but with git status
alias lg="lazygit"
# mise
# =================================
#
# [m]ise [r]egistry [s]earch # spellchecker:disable-line
alias mrs='mise registry | fzf'
# [m]ise [r]egistry [f]ind # spellchecker:disable-line
alias mrf='mise registry | fzf'
alias mi='mise install'
# easy alias to run tasks
alias mr='mise run'
# postgres
# --------
#
# Temporary Postgres Instance
alias pgtmp='docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_HOST_AUTH_METHOD=trust -v$(pwd)/tmp/pgdata:/var/lib/postgresql/data postgres:18-alpine'
# remove .orig files created after `git mergetool` is run
alias rmorig='rm $(fd --hidden "\.orig")'
# copy directory recursively
alias cpr='cp -r'
# file manager
alias y='yazi'
# Jira
# transition issue
jt() {
jira i "$(jira i | fzf | awk '{ print $1 }')" -t
}
alias tree="erd -I --hidden --no-git --dir-order last --layout inverted --sort name --human --no-ignore"
alias gtree="erd -I --hidden --no-git --dir-order last --layout inverted --sort name --human"
# tree paged
treep() {
tree --color=force "$@" | less
}
# gtree paged
gtreep() {
gtree --color=force "$@" | less
}
# Bundler
alias b="bundle"
# SSH fix for working with xterm-color256-italic
alias ssh="TERM=xterm-256color ssh"
# You-Get
alias yg='you-get'
# Rails
alias migrate="be rails db:migrate db:rollback && be rails db:migrate"
alias rof="rspec --only-failures"
alias be='bundle exec'
# Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"'
# Typos
alias quit="exit"
alias cd..="cd .."
alias vim.="vim ."
alias fap='gap'
# git reset empty files
gref() {
command git --no-pager diff --cached --stat | command grep " |\\s*0$" | awk '{system("command git reset " $1)}'
}
# Git
alias gap="git add -p"
alias gnap='git add -N . && gap && gref'
alias gan='git add -N'
alias gdn='git diff | diffnav'
# disable zsh git plugin
alias gsr='gst'
alias gcd1='git clone --depth=1'
# create a wip commit
alias gwip='git add . && git commit -m "chore: wip"'
# only add deleted files
alias gad='git ls-files --deleted | xargs git add'
alias gprune='gf --prune && git branch -vv | grep ": gone]" | grep -v "^[+*]" | awk "{print \$1}" | grep . | xargs git branch -D'
alias gclone='git clone'
# list all branches in a git bundle
alias gblh='git bundle list-heads'
# first commit sha
alias gfc='git rev-list --max-parents=0 HEAD'
# stash aliases
alias gsu='git stash -u'
alias gsp='git stash pop'
alias gsa='git stash --all'
# resume commit with previous message
alias gcr='git commit --verbose --edit --file=.git/COMMIT_EDITMSG'
# combines gbsum and tv
alias gctv='tv git-branch-checkout'
fork() {
repo_name=$(echo "$1" | xargs basename | cut -d. -f1)
clone_path="$HOME/dev/forks/$repo_name"
echo "Repo will be cloned to $clone_path"
git clone $1 "$clone_path"
cd $clone_path
}
# returns the first sha matching the selected branch
# this is useful when rebasing the branch to it's base to clean up things.
#
# git rebase -i $(base_sha)
base_sha() {
git fetch
branch=$(git branch --format='%(refname:short)' | fzf)
git show-ref refs/heads/$branch | awk '{ print $1 }'
}
# automate git fixup workflow with interactive fzf selection
# assumes staged files are part of the fixup and a clean working directory for
# the reabse
gfixup() {
branch=$(git branch --format='%(refname:short)' | fzf)
commit_sha=$(git log "$branch.." --pretty=oneline --color=always | fzf | awk '{ print $1 }')
git fixup $commit_sha
# there's probably a better way of doing this.. but good enough for now. This
# will try to stash unrelated changes, and pop them afterwards while avoiding
# a pop when a stash was not performed. Stashing is necessary because a rebase
# requires a clean working tree
if [[ "$(git stash -u | grep 'No local changes to save')" ]]; then
git rebase -i "${commit_sha}~1"
else
git rebase -i "${commit_sha}~1"
git stash pop
fi
}
# better git tree log:
alias gg='git log --graph --abbrev-commit --decorate --format=format:'\''%C(bold green)%h%C(reset) - %C(bold blue)%ai%C(reset) %C(bold red)%an%C(reset) %C(bold yellow)%d%C(reset)'\'\'' %C(dim white)- %s%C(reset)'\'
# create a draft PR from jira ticket name and number, based off a different
# branch
jpr() {
gh pr create --base $(gb --format='%(refname:short)' | fzf --border=rounded --prompt='Select base branch: ' --margin 25%) --draft --title "$(jira i | fzf --border=rounded --prompt='Select ticket: ' --margin 25% | ruby -ne 'i = $_.strip.split(/\s{2,}/); puts "[#{i[0]}] #{i[2]}"')"
}
# fancy weather
alias wttr='curl --silent https://wttr.in'
# howdoi (pip install howdoi) https://github.com/gleitz/howdoi
hdi() {
howdoi "$*" -c -n 5
}
# self-hosted ngrok clone
tnnl() {
local_port=$1
subdomain=$2
target_port="$(shuf -i 3000-65000 -n 1)"
echo "Creating encrypted tunnel at ${subdomain}.tnnl.me for local port ${local_port} ..."
ssh -i ~/.ssh/tnnl -tR "${target_port}:localhost:${local_port}" tnnl@tnnl.me /home/tnnl/SirTunnel/sirtunnel.py "$subdomain.tnnl.me" "$target_port"
}
# docker
alias dkc='docker container'
alias dcu='docker compose up'
alias dcd='docker compose up'
alias dps="docker ps"
alias dimg="docker image ls"
alias dprune="docker system prune -af" # Remove unused data
# usb
alias usbtree='ioreg -p IOUSB -l -w 0'
# fuzzy commands with fzf
alias gcorb='gco --track $(git branch -r --format="%(refname:short)" | fzf --prompt="Select remote branch to checkout: ")'
alias gcob='tv git-branch-checkout'
alias fz="fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort' --preview '[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'"
alias vfz='vim $(fz)'
alias preview="fzf --preview 'bat --color \"always\" --line-range 0:30 {}'"
alias fta='tmux attach -t $(tl | fzf | tr ":" "\n" | head -n1)'
alias ftk='tmux kill-session -t $(tl | fzf | tr ":" "\n" | head -n1)'
alias fcd='cd $(fd --type d --exclude node_modules --exclude vendor --exclude build --exclude _build --exclude bundle --exclude Godeps | fzf)'
# network utils
alias flushdns='sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder && echo cache flushed'
localip() {
ifconfig en0 | rg 'inet ' | awk '{print $2}'
}
# Usage: hr freethousand [port]
#
# Summary: Kill a process that is listening a port
#
# Help: Don't know where that Rails server is listening? Just freethousand!
# This command takes a port as an argument, otherwise defaulting to 3000.
freethousand() {
port="${1:-3000}"
pid="$(lsof -t -i tcp:$port)"
if [ -n "$pid" ]; then
echo "Killing process with PID $pid listening on port $port..." >&2
kill $pid
else
echo "No process listening on port $port" >&2
fi
}
alias vim='nvim'
alias vi='nvim'
alias vimdiff='nvim -d'
alias legacyvim='command vim'
# vim scratch - doesn't prompt to save a file on exit. Great for quick
# experiments and iterations on configs
alias vsc="nvim -c 'set buftype=nofile'"
# HomeBrew
alias brewup='brew upgrade'
# Search installed packages usage brewg lsusb
alias brewg='brew list | rg'
alias d='cd ~/dev'
alias dl='cd ~/Downloads'
alias f='cd ~/dev/forks'
alias dt='cd ~/dotfiles'
alias dots='cd ~/dotfiles'
alias hcd='cd ~/dev/hashrocket'
alias blog='cd ~/dev/sites/DorianKarter.com/blog'
alias docs='cd ~/Dropbox/Documents'
alias ss='imgur-screenshot.sh'
# debian
# creates a pbcopy command using xclip
command -v xclip >/dev/null && alias pbcopy='xclip -sel c'
alias gwork='gh dash --config ~/.config/gh-dash/work.yml'
alias lolcat='lolcrab'
# quick config
alias vimconfig='vim -o ~/.vimrc ~/.vimrc.bundles'
alias muxconfig='vim ~/.config/tmux/tmux.conf && tmux source-file ~/.config/tmux/tmux.conf'
alias sshconfig='vim ~/.ssh/config'
alias aliasconfig='vim ~/.aliases && source ~/.aliases'
alias hostsconfig='sudo nvim /etc/hosts'
alias zshconfig="vim -o ~/.zshrc && source ~/.zshrc"
alias gitconfig="vim ~/.gitconfig"
alias kittyconfig="vim ~/.config/kitty/kitty.conf"
alias vifmconfig="vim ~/.config/vifm/vifmrc"
# faster task alias
alias t=task
# tmux
alias mux='airmux'
# tmux new
function tn() {
local session_name=${1:-$(basename "$PWD")}
tmux new -s "$session_name"
}
# session manager using sesh + tv
# https://github.com/joshmedeski/sesh
alias s='tv sesh'
alias tgd='tv git-diff'
# tailscale cli - for when installed from the app store
alias tscale='/Applications/Tailscale.app/Contents/MacOS/Tailscale'
# tmux attach
alias ta='tmux attach -t'
# ripgrep - rg is taken by rails generate alias from the oh-my-zsh rails plugin
alias rgrep='command rg'
# curl
# usage postjson '{"key": "value"}' http://example.com/create_record
alias postjson='curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '
# usage postjson http://example.com/record/1
alias getjson='curl -i -H "Accept: application/json" -H "Content-Type: application/json"'
# convert any url to markdown - uses playwright to support dynamic sites
# usage: http2md https://diff.hex.pm/diff/tesla/1.15.3..1.16.0
alias http2md='docker run --rm ghcr.io/dkarter/http2md'
# rails
alias twiki='be rails db:migrate && be rails db:rollback && be rails db:migrate && be rails db:test:prepare'
alias dtp='be rails db:test:prepare'
# elixir
alias extwiki='mix ecto.migrate && mix ecto.rollback && mix ecto.migrate'
alias imix='iex -S mix'
alias im='iex -S mix'
alias mc='mix compile'
# mix compile check
alias mcc='mix compile --force --all-warnings --warnings-as-errors'
alias mpr='mix phx.routes'
alias mps='mix phx.server'
alias mt='mix test'
# resets the test database
alias mtr='MIX_ENV=test mix ecto.drop'
alias mdg='mix deps.get'
alias mdca='mix deps.clean --all'
alias ecto.reset='mix ecto.drop && mix ecto.create && mix ecto.migrate && mix ecto.seed'
alias killbeam='pgrep -f beam | xargs kill -9'
function mix_cmd_app() {
mix cmd --app $1 mix
}
# execute commands on umbrella apps
alias ma='mix_cmd_app'
# --------------------------------------------
# Pitchfork
# --------------------------------------------
alias pf='pitchfork'
# Workmux Aliases
# --------------------------------------------
# Core commands
alias wm='workmux'
alias wma='workmux add'
alias wmo='workmux open'
alias wmc='workmux close'
alias wmm='workmux merge'
alias wmrm='workmux remove'
alias wmls='workmux list'
alias wmp='workmux path'
alias wmd='workmux dashboard'
# Documentation
alias wmdocs='workmux docs'
alias wmcl='workmux changelog'
# Setup
alias wminit='workmux init'
# Claude integration
alias wmclaude='workmux claude'
# KEEP AT BOTTOM TO ALLOW OVERRIDE
# Include machine specific aliases
[ -f ~/.aliases.local ] && source ~/.aliases.local