-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.aliases
118 lines (91 loc) · 4.19 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
# replace common utilities with some improved replacements
alias cat='bat --wrap=never'
alias find='fd'
alias ls='eza -l --group-directories-first'
alias tree='tre --limit 3'
alias j='just'
alias fixcamera="sudo killall VDCAssistant; sudo killall AppleCameraAssistant"
# most recently modified file
alias recent-file="exa -s modified --reverse | head -n 1"
# pbcopy does not allow you to mutate public.html
alias pbcopy-html="pbpaste | hexdump -ve '1/1 \"%.2x\"' | xargs printf 'set the clipboard to {«class HTML»:«data HTML%s»}' | osascript -"
# copy last shell command into the clipboard
# fc -l == history builtin, awk command to remove trailing newline
alias clast="fc -ln -1 | awk '{printf \"%s\", \$0}' | pbcopy"
# TODO the username on this needs to be dynamic in some way
alias pisync='rsync -avh --filter=":- .gitignore" --progress $PWD [email protected]:~'
# fancier ping
alias ping='prettyping --nolegend'
# List all files colorized in long format, including dot files
alias la="eza -laF --group-directories-first"
# List only directories
alias lsd='eza -l -D'
# page so we get the full command output
alias pss="ps -eo user,pid,ppid,stat,etime,cmd --forest | less -S"
# IP addresses & network
alias default-network-device="route get default | grep 'interface:' | awk '{print \$2}'"
alias publicip="dig +short myip.opendns.com @resolver1.opendns.com"
alias dhcp-packet-info="ipconfig getpacket \$(default-network-device)"
alias localip="ipconfig getifaddr \$(default-network-device)"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
alias whois="whois -h whois-servers.net"
# Flush Directory Service cache
alias flushdns="sudo killall -HUP mDNSResponder && sudo dscacheutil -flushcache && sudo killall -HUP configd && echo 'All caches flushed.'"
alias flushdns="sudo killall -HUP mDNSResponder; sudo dscacheutil -flushcache"
# View HTTP traffic
alias sniff="sudo ngrep -d 'en0' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en0 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# Start an HTTP server from a directory
alias server="(sleep 0.1 && open http://localhost:8080/) & python -m http.server 8080"
# Trim new lines and copy to clipboard
alias c="tr -d '\n' | pbcopy"
alias p="cd ~/Projects"
# Edit current directory
alias e="code ."
alias o="open_in_nano ."
# File size
alias fs="stat -f \"%z bytes\""
alias ds="du -sh"
# git
alias g="git"
alias gp="g push origin HEAD"
alias gpb='g pull --rebase origin `git rev-parse --abbrev-ref HEAD`'
alias gpf='g push --force origin HEAD'
# github copilot
alias "sh?"="gh copilot suggest --target shell"
alias "gh?"="gh copilot suggest --target gh"
alias "git?"="gh copilot suggest --target git"
# rails
alias b="bundle"
# elixir
alias imix="iex -S mix"
# docker
alias d="docker"
alias dc='docker-compose'
# containers, networks, and ports + truncation
alias d-ps-network='docker ps --format "{{.ID}} {{.Names}} {{.Networks}} {{.Ports}}" | awk "{if(length(\$4) > 17) \$4 = substr(\$4, 1, 17) \"...\"; printf \"%s %s %s %s\n\", \$1, \$2, \$3, \$4}" | column -t'
# python
# TODO maybe fail if not in a venv
alias ipdb="ipdb3"
alias play="./playground.py"
alias po="poetry"
alias py=python
alias pyt=pytest
alias pytd="pytest --pdb -s"
alias po-pristine="poetry env remove --all -n && poetry install && (poetry shell && py-debugging-install)"
# g add poetry.lock && g checkout --theirs poetry.lock && po lock && git add poetry.lock && git rebase --continue
alias po-tree="poetry show --tree"
alias pipu="pip uninstall -y"
# TODO maybe make this accept URLs and convert to git reference?
alias pipi="pip install -U"
# TODO use --exec here instead
alias py-remove-pycache="fd --no-ignore-vcs __pycache__ | xargs rm -rf"
alias py-venv-path="python -c 'import site; print(site.getsitepackages()[0])'"
# alias py-venv="cd $(py-venv-path)"
alias py-spy-all="ps aux | grep '[p]ython' | awk '{print \$2}' | xargs -I {} py-spy dump --pid {}"
# TODO why not just add /usr/libexec to the path?
# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it
alias plistbuddy="/usr/libexec/PlistBuddy"
alias htop="htop --sort-key=PERCENT_CPU"
# https://tailscale.com/kb/1080/cli?tab=macos
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"