forked from kballenegger/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.shellrc
300 lines (219 loc) · 7.82 KB
/
.shellrc
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
#!/bin/sh
# NOTE: shebang so vim syntax highlights
# ----------------------------------------------------------------- #
# #
# Kenneth Ballenegger's Awesome .shellrc #
# #
# ----------------------------------------------------------------- #
# -----------------------------------------------------------------
# SHELL CONFIGURATION
# -----------------------------------------------------------------
export EDITOR="vim"
export CLICOLOR="xterm-color"
export DISPLAY=:0.0
# path
export PATH="$HOME/bin:$PATH"
export PATH="/usr/class/cs143/cool/bin:$PATH"
# command_exists
command_exists () {
type "$1" &> /dev/null ;
}
# -----------------------------------------------------------------
# BUILD TOOLS
# -----------------------------------------------------------------
if command_exists clang; then
export CC="clang"
fi
# -----------------------------------------------------------------
# APACHE, MYSQL, VERTICA, PHP
# -----------------------------------------------------------------
# apache
export PATH="/opt/local/apache2/bin:$PATH"
# mysql
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH="/opt/local/lib/mysql5/bin:$PATH"
alias mysql='mysql5'
# vertica
alias vsql="/opt/vertica/bin/vsql -h 10.79.61.102 -U super_reader -w 67Unic0rns"
# php
export PATH="/usr/local/php/bin:$PATH"
# php
alias cbsh="phpsh php/paraglide.php"
# -----------------------------------------------------------------
# GIT, RUBY, PYTHON, CLOJURE, NODE, COFFEE, LESS
# -----------------------------------------------------------------
# git
export GIT_EDITOR="vim"
# github credentials
if command_exists security; then
export GITHUB_USER=`security find-generic-password -D github | ruby -ne 'if (m = /"acct"\<blob\>\="([a-zA-Z0-9]+)"/.match($_)); print m[1]; end'` 2>/dev/null
export GITHUB_PASSWORD=`security find-generic-password -D github -w` 2>/dev/null
fi
alias gco="git checkout"
alias gps="git push"
alias gpl="git pull"
alias gm="git merge"
alias gcm="git commit -m"
alias gc="git commit"
alias gs="git status"
alias gb="git branch"
alias gd="git diff"
alias gcp="git cherry-pick"
alias ga="git add"
alias gmv="git mv"
alias grm="git rm"
# rubygems
export PATH="/Users/kenneth/.gem/ruby/1.8/bin:$PATH"
alias bundle-install-ser="bundle install --gemfile=ruby/Gemfile"
# rvm
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then
source $HOME/.rvm/scripts/rvm
fi
# note this needs to be after rvm, otherwise wrong ruby will be used
if command_exists hub; then
eval "$(hub alias -s)"
fi
# python
alias pyi="easy_install"
#clojure
alias pyclj="clojurepy"
alias cake="/Users/kenneth/.rvm/gems/ruby-1.9.2-p290/gems/cake-0.6.3/bin/cake"
# node
export NODE_PATH="/usr/local/lib/node"
alias less-watch="coffee ~/lib/lessc-watch/src/lessc-watch.coffee . ."
# go
command_exists brew && brew ls go | grep vim >/dev/null && \
export GOROOT=`brew ls go | grep vim | head -n 1 | ruby -ne 'Process.exit(1) unless $_ =~ /^(.+)\/misc\/vim/; puts $1'`
# -----------------------------------------------------------------
# PACKAGE MANAGER CONFIGUREATION
# -----------------------------------------------------------------
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
export PATH="/usr/local/bin:$PATH"
# -----------------------------------------------------------------
# CHARTBOOST-SPECIFIC CONFIGURATION
# -----------------------------------------------------------------
# bin path for scripts on server nodes
export PATH="/var/www/server/current/scripts/bin:$PATH"
# paraglide-live / dev
alias paraglide-live="export PARAGLIDE_ENVIRONMENT=live"
alias paraglide-dev="export PARAGLIDE_ENVIRONMENT=dev"
function remote-deploy {
dest=$1; shift
ssh [email protected] -t -i ~/.ssh/cb.pem 'bash -c \"/ops/bin/cb-ctl -u '$USER' -a deploy -d '$dest' '$@'\"'
}
alias remote-deploy-firehose="ssh [email protected] -t -i ~/.ssh/cb.pem 'bash -c \"/ops/bin/cb-ctl --no-merge -a deploy-firehose -u '$USER'\"'"
#alias cd-cb="cd ~/dev/caffeine/server"
alias cd-current="cd /var/www/server/current"
# reverse proxy dev.chartboost.com:9999 traffic to localhost
alias cb-proxy='ssh -R 9999:localhost:80 dev -N'
# reverse proxy for xdebug sessions
alias xdebug-tunnel='ssh -R 19000:localhost:19000 dev -N'
# connect to mongo / chartboost
alias mcb='mongo localhost/chartboost'
# tail scribe logs
alias tail-production="ssh scribe 'tail -f /external/scribe/primary/httpd/httpd_current'"
#prettier tails with ruby
alias pretty-json-tail="ruby -rjson -n -e 'puts JSON.pretty_generate(JSON.parse(\$_))'"
# resque
alias resque-remote-web='ssh -L 8282:redis_queue:8282 && open http://localhost:8282/'
alias resque-kill="ps aux | grep \"resque-1.0\" | grep -v grep | awk '{print \$2}' | xargs kill"
# salt
function mcp-salt {
ssh mcp "salt $(printf \''%s'\'' ' "$@")"
}
# ssh into new nodes
function cb-ssh {
ssh -i ~/.ssh/cb.pem "cb@""$1"".caffeine.io"
}
# spin up client builds
export scd_host=scd-internal
export scd_branch=master
export scd_cmd=build-ul
function client-build {
ssh $scd_host <<CMD
cd /build/client
git fetch
git checkout $scd_branch
git merge origin/$scd_branch
./package $scd_cmd
git checkout master
CMD
}
alias client-build-qa="client-build"
alias client-build-release="scd_cmd=ul client-build"
# -----------------------------------------------------------------
# ALIASES
# -----------------------------------------------------------------
alias ssh-proxy='ssh -D 9999 azure -N'
alias ssh-reverse-http='ssh -R 9999:localhost:80 azure -N'
alias free='free -m'
alias flushdns='dscacheutil -flushcache'
# keep environment when doing sudo su
alias ssu='sudo su -m'
# figure out what the ips are
alias ip10="ifconfig | grep '10\\.'"
function fgr {
fgrep -r -n $@ .
}
function pbgist {
if [ -z $1 ]; then
_opt=""
else
_opt="-t $1"
fi
# export GITHUB_PASSWORD=`git config --get github.password`
_out=`pbpaste | tab2space | gist $_opt`
echo $_out | pbcopy
echo $_out
}
function macc {
if [ -z $1]; then
open /Applications/Macchiato.app
else
touch $1
open -a /Applications/Macchiato.app $1
fi
}
# -----------------------------------------------------------------
# LS, GREP AND DIRCOLORS
# -----------------------------------------------------------------
# we always pass these to ls(1)
LS_COMMON="-hBG"
# setup the main ls alias if we've established common args
test -n "$LS_COMMON" &&
alias ls="command ls $LS_COMMON"
# these use the ls aliases above
alias ll="ls -l"
alias l.="ls -d .*"
alias ll.="ls -dl .*"
alias lla="ls -al"
# grep colors
if echo hello|grep --color=auto l >/dev/null 2>&1; then
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
fi
# -----------------------------------------------------------------
# PATH MANIPULATION FUNCTIONS
# -----------------------------------------------------------------
puniq () {
echo "$1" |tr : '\n' |nl |sort -u -k 2,2 |sort -n |
cut -f 2- |tr '\n' : |sed -e 's/:$//' -e 's/^://'
}
# condense PATH entries
PATH=$(puniq $PATH)
#MANPATH=$(puniq $MANPATH)
# -----------------------------------------------------------------
# AMAZON EC2 KEY PATHS
# -----------------------------------------------------------------
export EC2_PRIVATE_KEY="/var/www/server/current/config/amazon.key.pem"
export EC2_CERT="/var/www/server/current/config/amazon.cert.pem"
# misc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
# -----------------------------------------------------------------
# SOURCING LOCAL .SHELLRC
# -----------------------------------------------------------------
if [ -f ~/.shellrc.local ]; then
source ~/.shellrc.local
fi