-
Notifications
You must be signed in to change notification settings - Fork 4
/
dot-zshrc
498 lines (429 loc) · 12.4 KB
/
dot-zshrc
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
$HOME/.zprofile
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="robbyrussell"
ZSH_THEME="gianu"
#ZSH_THEME="kardan"
#ZSH_THEME="mortalscumbag"
#ZSH_THEME="pygmalion"
#ZSH_THEME="simple"
#ZSH_THEME="steeef"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment to change how often before auto-updates occur? (in days)
# export UPDATE_ZSH_DAYS=13
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want to disable command autocorrection
DISABLE_CORRECTION="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
# Uncomment following line if you want to disable marking untracked files under
# VCS as dirty. This makes repository status check for large repositories much,
# much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git brew httpie knife)
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
#export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
### PATH
export PATH=$HOME/bin:/usr/local/bin:$PATH
## Homebrew, at front of PATH
export PATH=/opt/homebrew/bin:$PATH
eval "$(/opt/homebrew/bin/brew shellenv)"
export LDFLAGS="-L/opt/homebrew/opt/curl/lib"
export CPPFLAGS="-I/opt/homebrew/opt/curl/include"
# Dropbox bin to PATH
if [ -d $HOME/Dropbox/bin ]; then
export PATH=$PATH:$HOME/Dropbox/bin
fi
## Docker in PATH, if Docker's installed
if [ -d $HOME/.docker/bin ]; then
export PATH=$PATH:/$HOME/.docker/bin
fi
## Adding ipython3 & friends to PATH
#export PATH=/usr/local/opt/[email protected]/bin:$PATH
## Adding a Ruby & gems to PATH
#export PATH=$PATH:/usr/local/opt/ruby/bin
## Adding Go's $GOPATH/bin to PATH
#export GOPATH=$HOME/Dropbox/code/gocode
#export GOBIN=$GOPATH/bin
#export PATH=$PATH:$GOBIN
#export PATH=$PATH:/usr/local/lib/ruby/gems/2.6.0/bin
## Python envvars which should help Sphinx work
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
## Vim
export EDITOR='vim'
### Mac Specifics
if [[ "$OSTYPE" == "darwin"* ]]; then
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
alias nap='pmset sleepnow'
alias komodo='open -a "Komodo Edit 9"'
alias eclipse='/Applications/Eclipse.app/Contents/MacOS/eclipse --clean $@'
alias ec='eclipse'
### Mac cursor commands for iTerm2; map ctrl+arrows or alt+arrows to fast-move
# for ctrl+arrows:
#"\e[1;5D": backward-word
#"\e[1;5C": forward-word
# for alt+arrows:
bindkey -e
bindkey '^[[1;9C' forward-word
bindkey '^[[1;9D' backward-word
bindkey '\e\e[D' backward-word
bindkey '\e\e[C' forward-word
function brb() {
open -a Preview $HOME/GoogleDrive/Projects/BRB/brb.png
}
fi
### If Work...
if [[ `egrep 'disney|starwave' /etc/resolv.conf` ]]; then
source $HOME/.work;
# alias spork='knife spork $@'
# alias block='knife block $@'
fi
### WORK
# source $HOME/.work
### FUNCTIONS
# # mkcd = create a directory and `cd` into it
mkcd() { mkdir -p "$@" && cd "$_"; }
# # chefsum = do a sha256 checksum on a file. So named because sha256 checksums is what Chef uses.
#chefsum() { openssl dgst -sha256 "$@"; }
function fuck() {
if killall -9 "$2"; then
echo ; echo " (╯°□°)╯︵$(echo "$2"|toilet -f term -F rotate)"; echo
fi
}
function iloop()
{
# Make this a function
# #while sleep 2; do echo && echo thinking; echo ; done
}
lint() {
if [ $1 ]; then
target=$1
else
target="."
fi
if
if [ `which rubocop` ]; then
echo "Running RuboCop";
rubocop $target;
else
echo "\nWARNING: RuboCop is not installed\n";
fi
if [ `which foodcritic` ]; then
echo "\nRunning Foodcritic\n";
foodcritic $target;
else
echo "\nWARNING: FoodCritic is not installed\n";
fi
}
cheflint() {
if [ $1 ]; then
target=$1
else
target="."
fi
if
if [ `which rubocop` ]; then
echo "Running RuboCop";
chef exec rubocop $target;
else
echo "\nWARNING: RuboCop is not installed\n";
fi
if [ `which foodcritic` ]; then
echo "\nRunning Foodcritic\n";
chef exec foodcritic $target;
else
echo "\nWARNING: FoodCritic is not installed\n";
fi
}
# function bd() {
# boot2docker $*
# #[[ "$1" == "up" ]] && eval "$(boot2docker shellinit)"
# if [[ "$1" == "up" ]]; then
# eval "$(boot2docker shellinit)";
# fi
# }
# dockerip() {
# boot2docker ip 2> /dev/null;
# }
# function subl () {
# #TODO: wrap in OS detection
# if [ -d /Applications/Sublime\ Text\ 2.app ]
# then
# /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl $@
# else
# echo "Sublime Text doesn't seem to be installed"
# fi
# }
editlaunchers() {
subl ~/Dropbox/Code/Launchers;
}
editdotfiles() {
subl ~/Dropbox/Code/dotfiles;
}
# tunnel() {
# echo "ssh -L 9909:192.168.1.1:80 home"
# echo "# Connections to tcp localhost:9909 will be made to 192.168.1.1:80 via SSH tunnel to home"
# }
# Where is a function defined?
whichfunc() {
whence -v $1
type -a $1
}
bio() {
cat $HOME/GoogleDrive/Presentations/_bio.txt
}
# Useful for converting between Graphite metrics and file paths
function dottoslash() {
echo $1 | sed 's/\./\//g'
}
function slashtodot() {
echo $1 | sed 's/\//\./g'
}
function spork() {
knife spork $@
}
function cwd() {
echo "${PWD##*/}"
}
function cookprepr() {
PATCH='patch'
semver=${2:-$PATCH}
# spork bump $cwd $semver && \
# knife cookbook metadata from file metadata.rb && \
# berks update && \
# git status
# echo "Next create your PR and get it merged."
# echo "When that's done, run \`cookpostpr\`"
}
function cookpostpr() {
# fetchupstream && \
# berks upload && \
# stove && \
# git push upstream master --tags && \
# echo "Now run \`berks apply {chef_environment}\`"
}
## Deprecating in favor of CLI tool
# function yamllint() {
# for i in $(find . -name '*.yml' -o -name '*.yaml'); do echo $i; ruby -e "require 'yaml';YAML.load_file(\"$i\")"; done
# }
function yamltojson() {
echo "python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < file.yaml > file.json"
}
function mp4_to_gif() {
filein=$1
fileout=$2 || "$1.gif"
ffmpeg -i $filein -f gif $fileout
}
function cleanlink() {
# First iteration
# curl -ILs -w %{url_effective} $1
#
# Links to further parse output:
# https://stackoverflow.com/a/6174447/428779
# https://unix.stackexchange.com/a/325492/7078
# https://gist.github.com/joshisa/297b0bc1ec0dcdda0d1625029711fa24
#
# Split on '?' and '&':
# link=$(curl -ILs -w %{url_effective} $1 | sed -E 's/&/\n\&/g;' | sed -E 's/\?/\n\?/g;')
# echo $link
curl -ILs -w %{url_effective} $1 | sed -E 's/&/\n\&/g;' | sed -E 's/\?/\n\?/g;'
}
# function datediff(){
# if [ -z "$1" ]
# then
# echo "The end date needs to be provided in 'YYYY-mm-dd' format" # Or no parameter passed.
# else
# echo "-Parameter #1 is \"$1\".-"
# fi
# future=$(date -j -f "%Y-%m-%d" $1 "+%s")
# now=$(date +%s)
# datediff=($future - $now)
#
# function daystododrox(){
# days=$(datediff(2016-04-21))
# echo "$days days to DevOpsDays Denver"
# }
function lowercase() {
echo $@ | tr '[:upper:]' '[:lower:]'
}
alias lower='lowercase'
alias lcase='lowercase'
function uppercase() {
echo $@ | tr '[:lower:]' '[:upper:]'
}
alias upper='uppercase'
alias ucase='uppercase'
function 8601zulu() {
echo $(date -u +"%Y-%m-%dT%H:%M:%SZ")
}
function 8601local() {
echo $(date +%FT%T%z)
}
# Colorized man pages, from:
# http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized
man() {
env \
LESS_TERMCAP_md=$(printf "\e[1;36m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
### BS FUNCTIONS
snow() {
clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS));sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH*\033[0;0H",a[x],x;}}'
}
happydance() {
echo ";D=-<\n"
echo ";D|-<\n"
echo ";D\-<\n"
echo ";D|-<\n"
echo ";D/-<\n"
echo ";D|-<\n"
}
disco() {
echo "(•_•)"
echo "<) )╯"
echo " / \ "
echo ""
echo "\(•_•)"
echo " ( (>"
echo " / \ "
echo ""
echo " (•_•)"
echo "<) )>"
echo " / \ "
}
fliptable() { echo "(╯°□°)╯ ┻━┻"; } # Flip a table. Example usage: fsck -y /dev/sdb1 || fliptable
monocle() { echo "ಠ_ರೃ\n"; }
csiyeah() { echo "(•_•) , ( •_•)>⌐■-■ , (⌐■_■)"; }
csiyeah-ani() {
echo -en "(•_•) \r"; sleep .4
echo -en "( •_•)>⌐■-■\r"; sleep .4
echo "(⌐■_■) "; sleep .4
}
shrug() { echo "¯\_(ツ)_/¯"; }
function rageflip() {
echo;
echo -n "( º_º) ┬─┬ \r"; sleep .4;
echo -n " ( º_º) ┬─┬ \r"; sleep .4;
echo -n " ( ºДº)┬─┬ \r"; sleep .4;
echo -n " (╯'Д')╯︵⊏ \r"; sleep .3;
echo -n " (╯'□')╯︵ ⊏ \r"; sleep .3;
echo -n " (╯°□°)╯︵ ┻━┻ "; sleep .3;
}
function flip() { # courtesy of Savant
echo;
echo -en "( º_º) ┬─┬ \r"; sleep .2;
echo -en " ( º_º) ┬─┬ \r"; sleep .2;
echo -en " ( ºДº)┬─┬ \r"; sleep .2;
echo -en " (╯'Д')╯︵⊏ \r"; sleep .1;
echo -en " (╯'□')╯︵ ⊏ \r"; sleep .1;
echo " (╯°□°)╯︵ ┻━┻"; sleep .1;
return 0
}
function heartthrob(){
echo ""
echo "< 3"
echo "< 3"
echo "<3"
echo "< 3"
echo "< 3"
echo "< 3"
echo "<3"
echo "< 3"
echo "< 3"
echo "< 3"
echo "<3"
echo ""
}
function annoyatron() {
dd if=/dev/urandom bs=7 count=100 | base64 | say -v "Trinoids"
}
function grieg() {
say -v Cello "do do do do do do do do do do do do do do do do do do do do do do do do do do"
}
function ughprint() {
echo "Print is Dead: https://youtu.be/D3v_ogRaTf4?t=10s"
echo "Ugh, Hardcopy: https://www.youtube.com/watch?v=K3zkqjpQF8U"
}
function status() {
echo "http://imgs.xkcd.com/comics/success.png"
}
function fixit() {
echo "https://www.youtube.com/watch?v=1Isjgc0oX0s"
}
function rip_psx(){
echo 'dd if=/dev/disk4 of="./Disk Title disk2.img" bs=2048; say "psx rip done"'
}
function backup_music(){
cd /Volumes/Music
rsync -avz --progress ~/Music/ .
}
function best(){
echo "https://youtu.be/oomCIXGzsR0?t=39"
}
### ALIASES
alias py3='python3'
alias py='py3'
alias bigdirs='du --max-depth=1 2> /dev/null | sort -n -r | head -n20'
# alias runningvms='VboxManage list runningvms'
alias flipdesk='fliptable'
alias deskflip='fliptable'
alias tableflip='fliptable'
alias cls='clear'
alias diff='colordiff'
alias prettyprint='python -m json.tool'
# alias vssh='vagrant ssh $1'
# alias vsssh='vagrant ssh $1'
# alias vstatus='vagrant status'
# alias vnuke='vagrant destroy -f'
# alias vcycle='vagrant destroy -f && vagrant up'
alias updatethese='for i in `ls`; do echo "\n$i"; cd $i; git pull; cd ..; done'
#alias fetchupstream= 'for i in `ls`; do echo "\n$i"; cd $i; git fetch upstream && git checkout master && git merge upstream/master && git push; cd ..; done'
alias fetchupstream='git fetch upstream && git checkout main && git merge upstream/main && git push'
alias forkandclone=''
alias whileloop='echo "while true; do sleep 2 && echo \"GO\!\" && dosomething; done"'
alias notdiff="echo are you looking for \'comm\'\? (for \"common\")"
alias diffvs='notdiff'
alias ipcalc='sipcalc'
alias tf='terraform'
alias k='kubectl $@'
# alias k='kitchen $@'
# alias kitch='kitchen $@'
alias linkme='cleanlink $@'
alias urthebest='best'
alias yourethebest='best'
### TYPO ALIASES
alias cleawr='clear'
# Report the execution time if it is longer than N seconds:
REPORTTIME=1
# List TMUX sessions, if any
tmux list-sessions 2> /dev/null
# Adding date ZSH
preexec() {
echo "$fg[black]`date`$reset_color"
echo
}
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /opt/homebrew/bin/terraform terraform