-
Notifications
You must be signed in to change notification settings - Fork 3
/
alf.conf
361 lines (245 loc) · 9.65 KB
/
alf.conf
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
#a
all-groups: cut -d: -f1 /etc/group | sort
ag: ag --color-match "1;36"
# agx <extension> <search pattern>
agx: ag -G$@
awatch: watch $(alf which $@)
#b
be: bundle exec
beep: echo -e '\a'
binlink: sudo ln -s "$1" "/usr/local/bin/$(basename "$1")"
#c
cachemem: cat /sys/fs/cgroup/memory/memory.stat |grep cache
flush: !sudo sysctl vm.drop_caches=3
cats: highlight --line-numbers --line-number-length=3 --line-length=75 --wrap-simple --wrap-no-numbers --out-format=ansi --force
cidr: sipcalc
# cd to next/prev sibling
cdnext: cd ../"$(ls -F .. | grep '/' | grep -A1 -xF "${PWD##*/}/" | tail -n 1)"
cdprev: cd ../"$(ls -F .. | grep '/' | grep -B1 -xF "${PWD##*/}/" | head -n 1)"
cert-refresh: sudo update-ca-certificates --fresh
clean: sudo apt autoremove && sudo apt clean && sudo apt autoclean && gem clean && sudo journalctl --vacuum-time=3d && rm -rf ~/.cache && d clean
hard: --volumes
codeclimate: docker run --rm -it -e CODECLIMATE_CODE=$PWD -e CODECLIMATE_DEBUG -v $PWD:/code -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/cc:/tmp/cc codeclimate/codeclimate "$@"
colortest: colortest-256
compare-dir: diff --brief -Nr
# Count files in folder. Folder name is optional
count: ls -1 ${1:-.} | wc -l
ctop: ctop -i
#d
d: docker
b: build -t ${1:-temp} .
clean: system prune -f
deploy: stack deploy -c $1.yml $1
df: system df --format "table {{.Type}}\t{{.TotalCount}}\t{{.Size}}\t{{.Reclaimable}}"
i: images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
images: images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
m: !docker-machine
machine: !docker-machine
n: network
ps: ps --format "{{.ID}} {{.Names}}\t{{.Status}} {{.Ports}}"
r: run -it --rm
replicas: service ls --format='table {{.Name}}\t{{.Mode}}\t{{.Replicas}}'
rmi: images --format "{{.Repository}}:{{.Tag}}" |grep $1 | xargs docker rmi -f
rmv: volume ls --format "{{.Name}}" |grep $1 |xargs docker volume rm -f
s: service
size: images --format '{{.Size}}\t{{.Repository}}:{{.Tag}}' | sort -h | column -t
st: stack
stats: stats --format "{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"
unzip: load -i $1.tar.gz
v: volume
vls: volume ls | grep -i
zip: save $1 | gzip > $2.tar.gz
dc: docker-compose
b: build
r: run --rm
ci: -f.ci/docker-compose.yml
ls: config --services
upd: up -d
deploy: !docker stack deploy -c docker-compose.yml
dclf: dc logs -f
dcr: dc r
decrypt: gpg2 -d
forget: !echo RELOADAGENT | gpg-connect-agent
dfh: df -h |grep "sd\|vd"
diagram: dot "$1" -Tpng -o "${1%.dot}.png"
dif: diff -u --color
dirfind: sudo find . -maxdepth ${2:-3} -type d -name "*$1*"
dm: docker-machine
dns: host -t ${2:-ns} $1
flush: !sudo systemd-resolve --flush-caches
stats: !sudo systemd-resolve --statistics
--flush: !dns flush && dns
help: !echo -e "Usage:\n dns example.com\n dns example.com mx\n dns --flush example.com\n dns flush\n dns stats"
# Show pizel size and DPI of an image
dpi: identify -units PixelsPerInch -format "Pixels: %w x %h\nDPI: %x x %y"
dps: d ps
dpsa: d ps -a
# docker swarm
ds: !
build: docker-compose -f $1.yml build
deploy: docker stack deploy -c $1.yml $1
launch: ds ls |xargs -L1 -i docker stack deploy -c {}.yml {}
# list / deploy / stop all (based on ls *.yml)
logs: docker service logs
ls: ls -1 *.yml | sed -e 's/\..*$//'
run: docker-compose -f $1.yml run ${@:2}
status: docker stack ls && echo ----- && docker service ls --format 'table {{.Name}}\t{{.Replicas}}'
stop: docker stack rm $1
terminate: ds ls |xargs -L1 docker stack rm
watch: watch -n5 "docker service ls --format 'table {{.Name}}\t{{.Replicas}}'"
dush: sudo du -sh
#e
encrypt: gpg2 -c
est: TZ=EST date
#f
f: find |grep
fd: fd --hidden --exclude .git
fingerprint: ssh-keygen -E md5 -lf
fonts: !
ls: fc-list
reload: fc-cache -f -v
install: sudo cp -r $1 /usr/share/fonts/truetype/
help: !echo -e "Usage:\n fonts ls # show list of fonts\n fonts reload # refresh cache after installing new fonts\n fonts install dejavu # copy the ./dejavu dir to the system fonts dir"
#g
g: git
# basic
b: branch
c: add . --all && git commit -am
d: diff --unified=0
m: merge
p: push
s: status
co: checkout
pl: pull
# commonly used
cl: changelog
tags: tag --sort v:refname
new: checkout -b
chmod: update-index --chmod
retag: tag $1 -f && (git push origin --delete $1 || true) && git push origin $1
discard: checkout -- . ; git clean -fd
remote-delete: push origin --delete
rebuild: commit --allow-empty -m "trigger rebuild" ; git push
rename: branch -m
rollback: diff --binary HEAD $1 | git apply
unstash: stash pop
# log related
l: log --all --graph --date=relative --pretty=format:'%h %Cgreen%ad%Creset %Cblue%an%Creset%n %s%n %C(auto)%d%Creset'
ll: log --graph --oneline --decorate --all
tail: log -${1:-5} --all --date=relative --pretty=format:'%h %Cgreen%ad%Creset %x09%Cblue%s%Creset'
datelog: log --pretty=format:'%C(cyan)%h %C(magenta)%ad %C(blue)%an%Creset%x09%s' --date=short
history: log -p
# less commonly used
ls: ls-tree --full-name --name-only -r HEAD
compare: diff --stat --color $1..HEAD
# optimize: repack -ad && sleep 4 && git gc --aggressive --prune=now
resolve-ours: checkout --ours . ; git add -u ; git commit -m 'resolve conflicts with --ours'
resolve-theirs: checkout --theirs . ; git add -u ; git commit -m 'resolve conflicts with --theirs'
shallow-clone: clone --depth 1
tagsha: show-ref --abbrev=7 --tags
sha: rev-parse --short HEAD
# git add-upstream user/repo
add-upstream: remote add upstream https://github.com/$1.git
fetch-upstream: checkout master && git fetch upstream && git merge upstream/master
# show age of all git repos in subdirectories
age: !for d in ./*/; do echo -e "\n\e[34m$d\e[0m" ; git -C $d log -1 --all --date=relative --pretty=format:'%Cgreen%ad%Creset %x09%s%n' ; done;
gg: g p
ggt: gg && gg --tag
gpl: g pl
ggc: g c "$*" && gg
geoip: curl http://ip-api.com/line/$1
# GitHub API - example usage: github /user/repos
github: curl -H "Authorization: token $GITHUB_ACCESS_TOKEN" https://api.github.com$1
#h
hey: tuxi -rq
historydel: for ((i = 1 ; i <= ${1:-1} ; i++)); do echo "clearing line $(($HISTCMD-2)): $(history -p \!$(($HISTCMD-2)))"; history -d $(($HISTCMD-2)); done; history -d $(($HISTCMD-1))
hk: heroku
https: http ${@:1:$((${#@}-1))} https://${@: -1}
#i
inst: sudo apt install
# Create animated gif - delay parameter is optional
jpg2gif: convert -delay ${1:-300} -loop 0 *.jpg animated.gif
#k
killport: [[ $(lsof -ti:$1) ]] && kill -9 $(lsof -ti:$1)
kl: kubectl
klg: kubectl get
#l
l: ls -lh
ll: ls -lah
less: less -Sr
log: if [[ "$1" == "" ]]; then cat log.log 2> /dev/null; else echo -e "$(date) : $*" >> log.log ; cat log.log; fi
#m
mdman: pandoc -s --to man $1 | man -l -
mem: watch free -h
monitor: gotop -lminimal
murder: sudo pkill -9
myip: dig +short myip.opendns.com @resolver1.opendns.com
myipint: hostname -I | awk '{print $1}'
#n
nameserver: systemd-resolve --status |head -n3
network: sudo lshw -class network -short
nv: env |grep -i
#o
outdated: /usr/lib/update-notifier/apt-check --human-readable && echo "Run 'outdated list' to show upgradable packages"
list: !apt list --upgradable
#p
# List installed perl modules
perlmod: perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'
# Create animated gif - delay parameter is optional
png2gif: convert -delay ${1:-300} -loop 0 *.png animated.gif
png2pdf: convert -units PixelsPerInch "$1" -density 300 "$(basename $1 .png).pdf"
port: sudo lsof -i :$1
ports: sudo netstat -tulpn | grep LISTEN |grep -Po '(?<=:)(\d{2,5})' |sort -n |uniq |tr '\n' '\t'
psf: ps -ef |grep
pt: papertrail
ppt: PAPERTRAIL_API_TOKEN=$PERSONAL_PAPERTRAIL_API_TOKEN pt
py: python3
#r
rbenv-doctor: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
redis: redis-cli
rv: rbenv
# repeat 5 echo hello
# repeat: for i in `seq $1`; do ${@:2} ; done
repo-info: curl -s https://api.github.com/repos/dannyben/$1 | jq '{name: .full_name, forks: .forks_count, stars: .stargazers_count, watchers: .watchers_count, issues: .open_issues_count, subscribers: .subscribers_count}'
runas: sudo su -s /bin/sh $1 -c "$2"
rsvg: rsvg-convert
#s
sad: ssh-add
search: grep -ri
senderscore: echo $1 | awk -F . '{print $4"."$3"."$2"."$1".score.senderscore.com"}' | xargs -I{} dig a {} +short | xargs -I{} echo {} | cut -d . -f 4
slim: slimrb --pretty
slurp: wget --recursive --no-clobber --level=${2:-10} --page-requisites --adjust-extension --convert-links --restrict-file-names=windows --no-parent http://$1
space: sudo ncdu --exclude /vagrant --exclude /store /
sshconf: vi ~/.ssh/config
ssh-testkey: ssh-keygen -t rsa -C "bobbo@henna.com" -f id_rsa -N ''
sslyze: docker run --rm -it nablac0d3/sslyze
# The ImageMagick convert method (disabled) has issues (and also needs inkscape installed)
# svg2png: convert -background none "$1" "$(basename $1 .svg).png"
svg2png: inkscape "$1" -e "$(basename $1 .svg).png" 2> /dev/null
syslog: sudo grc tail -f /var/log/syslog
#t
# tracert: sudo traceroute -I
tracert: mtr
triplet: gcc -dumpmachine
testssl: docker run --rm -ti drwetter/testssl.sh
#u
uninst: sudo apt remove
uml: java -jar /vagrant/java/plantuml/plantuml.jar
update: sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y
#v
ver: cat /etc/os-release
vir: vi -R
#w
what: alf which
wsh: readlink /proc/$$/exe
# open any command in a new tmux window or pane
ww: tmux new-window
ws: tmux split-window
#y
y2mp3: youtube-dl --extract-audio --audio-format mp3 "$@"
ytop: ytop --colorscheme default-dark
# caps
GET: http GET
POST: http POST
PUT: http POST
HEAD: http HEAD