-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsh_aliases
400 lines (313 loc) Β· 8.41 KB
/
zsh_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
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
alias today="vim $TODAY_PATH"
alias tomorrow="vim $TOMORROW_PATH"
# Utilities
unalias ll
alias git='hub'
alias grep='ggrep'
alias ll='ls -laG'
alias mkdri='mkdir'
alias c="clear"
alias vup="vagrant up"
alias vupp="vagrant up --provision"
alias vs="vagrant ssh"
alias vp="vagrant provision"
alias rn="react-native"
alias redis_start="redis-server /usr/local/etc/redis.conf"
alias redis_stop="redis-cli shutdown"
# md5sum
alias md5='md5 -r'
alias md5sum='md5 -r'
alias rncc='watchman watch-del-all && rm -rf node_modules && yarn cache clean && yarn && yarn start -- --reset-cache'
alias ni="npm i"
alias nis="npm i -s"
alias nr="npm run"
alias nrt="npm run test"
alias python=/usr/local/bin/python3
alias yarn="npm"
# Datestamp a tarball
function bak() {
cp $1 ${1}.bak
}
# Datestamp a tarball
function dtar() {
echo $1
echo $2
$fname=""
tar -rvf $(date +%F)_${1}.tar $2
}
alias taskui="bundle exec rake --tasks"
#
#
# workspace Utils
alias my_issues="~/workspace/lib/workspace-cli/get_issues.sh"
#
# vim Typos
#
alias ivm='vim'
alias ivn='vim'
alias iv='vim'
alias vin='vim'
alias cim='vim'
alias mcim='vim'
alias mim='vim'
alias fim='vim'
alias vimrc="vim ~/.vimrc"
#
# zsh Utils
#
alias zshrc="vim -O ~/.zshrc ~/.zsh_aliases"
#
# Navigation
#
alias wksp="cd $WORKSPACE"
alias logs="cd $WORKSPACE_LOG"
alias media="cd $WORKSPACE_MEDIA"
alias vwksp="vim $WORKSPACE"
alias vcode="vim $WORKSPACE_CODE"
alias vlogs="vim $WORKSPACE_LOG"
alias vmedia="vim $WORKSPACE_MEDIA"
alias r=rails
alias sr="screen -r"
alias :q="You're not in Vim"
alias :w="You're not in Vim"
alias diff=colordiff
# Personal Commands
alias es='exec $SHELL'
alias b='bundle install --path .bundle/gems --binstubs .bundle/bin'
alias be='bundle exec'
alias grh="git reset --hard"
alias push="git push origin HEAD"
alias pull="git pull origin HEAD"
alias pr="hub pull-request"
alias tree='git log --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset'\'' --abbrev-commit --date=relative'
alias gr='git reset'
alias cleanup_git='git fetch origin --prune'
# Bash wrappers
alias count='tee >(wc -l)'
# Jekyll Commands
alias js='jekyll serve'
alias jb='jekyll build'
alias gti='git'
alias vmi='vim'
alias vom='vim'
alias cim='vim'
# Sys Admin Commands
alias duh='du -csh'
alias dimage='du -hc *.png'
#start/stop postgres
alias pgstart='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias pgstop='pg_ctl -D /usr/local/var/postgres stop -s -m fast'
# Init
alias gsetup="git init && git aa && git ci -m 'initial'"
# Commit
alias gc="git ci -m $1"
alias gac="git aa && git ci -m $1"
# Push
alias gp="git push origin master"
alias gph="git push heroku"
# Remote
alias gro="git remote add origin"
alias bbro="git remote add origin git@bitbucket:igolden/$1"
# Arduino
alias pf="platformio platforms"
alias bbro="git remote add origin git@bitbucket:igolden/$1"
alias agno="vim .antigen/repos/https-COLON--SLASH--SLAcd .antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-robbyrussell-SLASH-oh-my-zsh.git/themes/"
function gacp() {
gac $1
gpo
}
function gach() {
gac $1
gph
}
# docker
alias stop_docker="docker stop $(docker ps -a -q)"
alias todo="bundle exec todo"
alias myip="curl ipecho.net/plain; echo"
alias hn="links 'news.ycombinator.com'"
alias gpg='gpg2'
function clear_docker {
echo "Removing docker containers.."
docker rm -f $(docker ps -a -q) &>/dev/null
echo "Done."
echo "Removing docker volumes.."
docker volume rm $(docker volume ls -q) &>/dev/null
echo "Done."
}
function kill_docker {
echo "Removing docker containers.."
docker rm -f $(docker ps -a -q) &>/dev/null
echo "Done."
echo "Removing docker images.."
docker rmi $(docker images) &>/dev/null
echo "Done."
echo "Removing docker volumes.."
docker volume rm $(docker volume ls -q) &>/dev/null
echo "Done."
}
function kill_volumes {
echo "Removing docker volumes.."
docker volume rm $(docker volume ls -q)
echo "Done."
}
# fix last command
alias fix='sudo $(history -p \!\!)'
# macdown
alias md="/Applications/MacDown.app/Contents/SharedSupport/bin/macdown"
function dcr {
image=$1
shift
docker-compose run $image $@
}
alias nis="npm install --save"
alias nisd="npm install --save-dev"
alias nu="npm upgrade"
alias nun="npm uninstall"
alias nug="npm update --global"
alias nung="npm uninstall --global"
alias dc='docker-compose'
alias dcc='docker-compose config'
alias dcu='docker-compose up'
alias dynamo='java -Djava.library.path=/Users/igolden/source/dynamodb/DynamoDBLocal_lib -jar /Users/igolden/source/dynamodb/DynamoDBLocal.jar -sharedDb -inMemory'
alias pamm='git push origin HEAD && git co master && git merge - && git push origin master'
function commit {
git aa && git commit -m "$1"
}
function bin() {
./bin/$1
}
function adjust_background() {
osascript -e "tell application \"iTerm\"
set current_terminal to (current terminal)
tell current_terminal
set current_session to (current session)
tell current_session
set background color to $1
end tell
end tell
end tell"
}
# Fast shortcuts
alias c='clear'
alias r='reset'
alias q='exit'
alias cd..="cd .." # I often make this mistake
alias cs="cd"
# Because sometimes you don't have the time to put this two letters
alias ..='cd ..'
alias ...='cd ../..'
alias -- -="cd -"
alias lcat="cat $1 | less"
alias nuke='kill -9 %%'
# up ..
function up {
if [[ "$#" < 1 ]] ; then
cd ..
else
CDSTR=""
for i in {1..$1} ; do
CDSTR="../$CDSTR"
done
cd $CDSTR
fi
}
function extract {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "ERROR: Don't know how to extract '$1'" ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
alias grep='ggrep'
# Search process by name and highlight !
function psgrep() { ps ax | grep -v grep | grep "$@" -i --color=auto; }
# Search for files and page it
function search() { find . -iname "*$@*" | less; }
# PKG INSTALLER
alias pk='brew'
alias eb='sudo eb'
alias awslogs='sudo awslogs'
function google {
if [ -z $1 ] ; then
echo "No first argument"
else
links "https://google.com/search?q=$1"
fi
}
commit_times() {
git log --author="Ian Golden" --format="%ad" --date="format:%H"|awk '{n=$1+0;if(H[n]++>max)max=H[n]}END{for(i=0;i<24;i++){printf"%02d -%5d ",i,H[i];for(n=0;n<H[i]/max*50;n++){printf "*"}print""}}'
}
docker_push_all() {
for img in "$@"; do docker push $img; done
}
get_pids() {
ps -ax | grep $1 | while read line ; do echo "$line" | grep -v 'grep' | grep -oh "^[0-9]*"; done
}
list_ssh() {
cat ~/.ssh/config
}
list_keys() {
ls -al ~/.keys/$1
}
mysql_start() {
sudo /usr/local/Cellar/mysql/8.0.12/support-files/mysql.server start
}
mysql_stop() {
sudo /usr/local/Cellar/mysql/8.0.12/support-files/mysql.server stop
}
ytmp3() {
youtube-dl $1 -x --audio-format mp3
}
dailies() {
vim ~/Desktop/TODO.md
}
alias clear_swap='rm /var/tmp/*.swp'
alias 85h='cd $EFHOME'
alias dotfiles="vim $DOTFILES_PATH"
alias download_file="curl -C - -L -O $1"
alias tmpnote="vim ~/workspace/tmp/$(date '+%Y-%m-%d-%H%M%S').md"
pgcheck() {
PGPASSWORD=mysecretpassword psql -U postgres -d servus_bbb_data_1 -h 10.1.10.86 -c "SELECT COUNT(*) FROM bbb_profiles" | awk 'c&&!--c;/count/{c=2}'
}
gitignoreio() {
curl --silent https://www.toptal.com/developers/gitignore/api/$1 >> '.gitignore'
}
gi() {
IFS=' '
read -A strarr <<< $@
# Print each value of the array by using the loop
for val in "${strarr[@]}";
do
echo "β· Added $val .gitignore entries"
gitignoreio $val
done
}
# Search your histfile for command and organize by frequency
hist() {
cat $HISTFILE | grep -Pa "$1" | cut -d ';' -f 2 | sort | uniq -c | sort -n
}
taskcount() {
cat ~/.task/backlog.data | grep -Po '(?<=\"status\":)\".*\"(?=,)' | uniq -c | sort -nr
}
taskeventcount() {
cat ~/.task/backlog.data | grep -Po '(?<=\"uuid\":)\".*\"(?=(,|))' | sort | uniq -c | sort -nr
}
alias taskui='taskwarrior-tui'
TODAY() {
date '+%Y-%m-%d'
}
alias grip="grip -b"
alias tasktui=taskwarrior-tui