-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
328 lines (264 loc) · 7.86 KB
/
.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
# zmodload zsh/zprof
# Check if Command is available:
# if ! type "$foobar_command_name" > /dev/null; then
# do stuff
# fi
# Check if file exists:
# if [[ -a file ]]; then
# do stuff
# fi
# Check for TTY
# if [[ "$(tty)" == '/dev/tty1' ]]; then
# exec startx; exit
# fi
# source $HOME/.profile
if [[ -d /usr/local/opt/emacs-mac/bin ]]; then
EMACS_BIN_DIR=/usr/local/opt/emacs-mac/bin
else
EMACS_BIN_DIR=/usr/local/bin
fi
export BUNDLER_EDITOR="$EMACS_BIN_DIR/emacs"
export EDITOR="$EMACS_BIN_DIR/emacs"
if [[ -a ~/dotfiles/antigen.zsh ]]; then
source ~/dotfiles/antigen.zsh
autoload -U colors && colors
setopt promptsubst
antigen bundle git
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen theme ~/dotfiles worace
antigen apply
fi
if [[ -a /usr/local/bin/virtualenvwrapper_lazy.sh ]]; then
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh
fi
if [[ -a $HOME/.local/bin/virtualenvwrapper_lazy.sh ]]; then
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=$HOME/.local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_PYTHON=$(which python3)
source $HOME/.local/bin/virtualenvwrapper_lazy.sh
fi
case `uname` in
Darwin)
#increase keyrepeat speed beyond os x allowed maximum
eval "defaults write NSGlobalDomain KeyRepeat -int 1"
alias vsc=/usr/local/bin/code
alias paste=pbpaste
alias copy=pbcopy
function alert {
terminal-notifier -message $1
}
em () {
if [ "$#" -ne 0 ];
then
$EMACS_BIN_DIR/emacsclient -c -n $*
else
$EMACS_BIN_DIR/emacsclient -c -n "~/Dropbox/notes/scratch.org"
fi
}
;;
Linux)
alias copy="xclip -selection clipboard"
alias paste="xclip -o -selection clipboard"
em () { emacs $* & disown }
export TERM=xterm-color
function alert {
notify-send $1
}
;;
esac
alias racket="/Applications/Racket\ v6.8/bin/racket"
function gitMainBranch() {
git remote show origin | sed -n '/HEAD branch/s/.*: //p' | tr -d '\n'
}
function gpom() {
git pull origin $(gitMainBranch)
}
# Git
alias gs='git status '
alias ga='git add .'
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias gds='git diff --staged'
alias gr='git remote -v'
alias gco="git checkout"
alias gst="git status"
alias gpum="git pull upstream master"
alias gpod="git pull origin develop"
alias hb="gh repo view --web"
alias be="noglob bundle exec"
alias bl="bundle --local"
alias la="ls -lah"
alias pd="pushd $*"
alias po="popd $*"
alias hist="cat ~/.zsh_history"
# GOLANG
export GOPATH=$HOME/go
export PATH=$PATH:"$GOPATH/bin"
export CC="gcc"
alias bounce_dns="sudo killall -HUP mDNSResponder"
# hdfs aliases
alias hfs='noglob hadoop fs'
alias hls='noglob hadoop fs -ls'
alias htx='noglob hadoop fs -text'
alias hc='noglob hadoop fs -cat'
if [[ -a ~/.secrets.sh ]]; then
source ~/.secrets.sh
fi
if [[ -a ~/.localrc ]]; then
source ~/.localrc
fi
if [[ -a ~/.factual.sh ]]; then
source ~/.factual.sh
fi
function killgrep {
kill $(ps aux | grep $1 | grep -v "grep" | awk '{print $2}')
}
function pgrep {
ps aux | grep $1 | grep -v "grep"
}
# Chruby for ruby version management
function loadChruby {
if [[ -a $1/chruby.sh ]]; then
source $1/chruby.sh
source $1/auto.sh
# chruby 2.6
fi
}
loadChruby '/usr/local/share/chruby'
loadChruby '/usr/share/chruby'
loadChruby '/opt/homebrew/opt/chruby/share/chruby'
if type ruby > /dev/null; then
# For adding system-ruby gem dir to path
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
fi
function scrape {
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains website.org \
--no-parent \
$1
}
function countloc { find $1 -name "*" -type f | xargs wc -l | sort -n }
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# alias nvmu='source ~/.nvm/nvm.sh && nvm use'
# Elixir
export ERL_AFLAGS="-kernel shell_history enabled"
export PATH="$PATH:$HOME/.mix/escripts"
alias mc="iex -S mix"
alias mps="mix phx.server"
alias mpr="mix phx.routes"
alias mdg="mix deps.get"
alias mt="mix test"
alias mpr="mix phx.routes"
HISTSIZE=100000
SAVEHIST=100000
HISTFILE="$HOME/.zsh_history"
# setopt hist_ignore_dups # ignore duplication command history list
# setopt append_history
# setopt extended_history
# setopt hist_expire_dups_first
# setopt hist_ignore_space
# setopt hist_verify
# setopt inc_append_history
setopt share_history
setopt interactivecomments
alias rl="source ~/.zshrc"
[ -f "$HOME/.travis/travis.sh" ] && source "$HOME/.travis/travis.sh"
# Custom thrift version needed for engine
PATH="/usr/local/opt/[email protected]/bin:$PATH"
# Hadoop + Kerberos Local Setup
export HADOOP_CONF_DIR=/etc/hadoop/neutronic-aws-conf
export HADOOP_USER_NAME=root
export HADOOP_CLASSPATH=/etc/hadoop/lib/jars/*
case `uname` in
Linux)
export HADOOP_HOME=/usr/lib/hadoop
export SPARK_HOME=/opt/spark
export PATH=$PATH:/opt/oozie/bin
export PATH=$SPARK_HOME/bin:$PATH
export PATH=$HADOOP_HOME/bin:$PATH
export OOZIE_URL=https://oozie-api.we-usw1-infra.k8s.foursquare.com/oozie
alias yrn=/usr/lib/hadoop/bin/yarn
;;
esac
function yarnlogs {
/usr/lib/hadoop/bin/yarn logs -applicationId $1 > /tmp/$1.log
}
function yarnkill {
yrn application -kill $1
}
# 'z' directory-switching utility
# https://github.com/rupa/z
. $HOME/dotfiles/z.sh
alias j=z
PATH=$PATH:$HOME/.local/bin
# tmux
alias tn="tmux new -s"
alias tls="tmux ls"
alias tl="tmux ls"
alias ta="tmux a -t"
alias i="sudo apt install"
function throughput {
tail -f $1 | pv -lrtab > /dev/null
}
alias jq="noglob jq -cr"
alias curl="noglob curl"
export PATH="$HOME/.cargo/bin:$PATH"
alias ldappw="op get item \"LDAP Factual\" | jq -cr .details.fields[0].value | copy"
alias jqc="jq -cr ."
alias jqcp="paste | jqc | copy"
alias jqp="\jq "
alias rake="noglob rake"
alias countries="ruby -e 'require \"factual_countries\"; FactualCountries.all.keys.each { |c| puts c }'"
alias count="sort | uniq -c | sort -nr"
export SBT_OPTS="-Xmx16G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M -XX:ReservedCodeCacheSize=512M -Dcom.unboundid.scim.sdk.debug.enabled=true"
function dockerprune {
docker image prune -f
docker container prune -f
}
function okiedokie {
mpg123 $HOME/data/okiedokie.mp3 2> /dev/null
}
function csv2json {
ruby -r csv -r json -e 'CSV.new(STDIN, headers: true).each { |r| puts r.to_h.to_json }'
}
function json2csv {
ruby -r set -r json -r csv -e 'rows = STDIN.readlines.map { |l| JSON.parse(l) }; keys = rows.map { |r| r.keys.to_set }.reduce(:union).to_a.sort; arrs = rows.map { |r| keys.map { |k| r[k] } }; CSV(STDOUT) { |csv| csv << keys; arrs.each { |a| csv << a } }'
}
export PATH="$HOME/.npm-global/bin:$PATH"
# zprof
function jqm {
jq "select(.$1 == \"$2\")"
}
function kubeexec {
kubectl --namespace airflow-prod exec $1 -it /bin/bash
}
if type "frum" > /dev/null; then
eval "$(frum init)"
fi
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
alias bta="./bazel test ..."
alias brp="REPIN=1 ./bazel run @unpinned_maven//:pin"
alias gitsha="git rev-parse --short HEAD"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
function scCase {
ruby -e "puts STDIN.read.gsub(\"//@ (\", \"\").gsub(\"'\", '\"').gsub(').should ==', ' -> ').gsub(/\n/, \",\n\").gsub(', meta!()', '')"
}
alias awp="aws --profile places-eng-poweruser"
export PATH="$PATH:/usr/local/go/bin"
eval $(cs java --jvm adopt:8 --env)
alias gcp="git cherry-pick"