-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosx_bashrc
297 lines (248 loc) · 7.55 KB
/
osx_bashrc
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
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/share/npm/bin:$HOME/gsutil:$PATH"
[[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh
alias ls='ls -G'
export CLICOLOR=1
export LSCOLORS=Gxfxcxdxbxegedabagacad
export JAVA_HOME=$(/usr/libexec/java_home)
export NODE_PATH="/usr/local/lib/node_modules"
export NODE_PATH='/usr/local/lib/jsctags:${NODE_PATH}'
export DYLD_FALLBACK_LIBRARY_PATH="/usr/local/Cellar/postgresql/9.4.4/lib":$DYLD_FALLBACK_LIBRARY_PATH
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
export PATH=/Users/samvit/builds/bin:$PATH
export GOPATH=$HOME/dev/go
export PATH=$HOME/dev/go/bin:$PATH
export HISTSIZE=20000
# append all commands to the history file, don't overwrite it at the start of every new session
shopt -s histappend
# Editor Aliases:
alias vim='mvim -v'
export EDITOR=vim
alias slime='subl'
# some more ls aliases
alias ll='ls -alhF'
alias la='ls -A'
alias l='ls -CF'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
alias ducks='du -cks *|sort -rn|head -11'
# spy () { lsof -i -P +c 0 +M | grep -i "$1" }
alias json="python -mjson.tool"
alias hs='history | grep --color=auto'
# Work Aliases
alias db='psql -d equidate-local'
alias feed-db='psql -d equifeed-local'
alias py='ipython'
alias eshell='sh harness.sh'
alias h='heroku'
alias proddb='heroku pg:psql cyan --app equidate'
#custom Aliases
alias '..'='cd ..'
alias '...'='cd ../..'
alias junk='cd ~/junk'
alias os='cd ~/dev/CS162-Stuff'
alias comp='cd ~/dev/CS164-Stuff/'
alias dev='cd ~/dev'
alias dbox='cd ~/Dropbox\ \(Personal\)'
alias todo='vim ~/Dropbox/notes/todo.txt'
alias jokes='vim ~/Dropbox/Notes/Jokes.txt'
alias e='cd ~/dev/equi/'
alias eq='cd ~/dev/equi/equidate/ && pipenv shell'
alias feed='cd ~/dev/equi/equifeed && source venv/bin/activate'
alias f='cd ~/dev/fabric/'
alias box='cd ~/dev/minbox/'
alias monk='cd ~/dev/mailmonkey'
alias site='cd ~/dev/personal-website/'
alias ss='cd ~/dev/s2/s2capital-scripts && source venv/bin/activate'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias rm='trash'
# alias rm='mv -f \!* ~/.deleted/'
# alias unrm='mv ~/.deleted/\!* .'
alias gs='git status'
alias gpm='git push origin master'
alias gl="git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias glog='git log --pretty=format:"[%h] %ae, %ar: %s" --stat'
alias gtree='git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport '
# glf = git log first
alias glf='gl | head -n 15'
function gc () {
git checkout $@;
};
function gcm () {
git commit -m "$@";
};
function gb () {
git branch $@;
};
function gbd () {
git branch -D $@;
};
function gd () {
git difftool $@;
};
function gpll () {
git pull $@;
};
function gpsh () {
git push $@;
};
function gup () {
git up $@;
};
pull_request() {
to_branch=$1
if [ -z $to_branch ]; then
to_branch="master"
fi
# try the upstream branch if possible, otherwise origin will do
upstream=$(git config --get remote.upstream.url)
origin=$(git config --get remote.origin.url)
if [ -z $upstream ]; then
upstream=$origin
fi
to_user=$(echo $upstream | sed -e 's/.*[\/:]\([^/]*\)\/[^/]*$/\1/')
from_user=$(echo $origin | sed -e 's/.*[\/:]\([^/]*\)\/[^/]*$/\1/')
repo=$(basename `git rev-parse --show-toplevel`)
from_branch=$(git rev-parse --abbrev-ref HEAD)
open "https://github.com/$to_user/$repo/pull/new/$to_user:$to_branch...$from_user:$from_branch"
}
alias eb="vim ~/.bashrc"
alias sb="source ~/.bashrc"
alias ev="vim ~/.vimrc"
alias es="vim ~/.dotfiles/mac_setup_script.sh"
function server () {
python -m SimpleHTTPServer $@
}
# Run ls whenever I cd somewhere
function cd () {
builtin cd "$@" && ls;
}
#better bash history navigator - up and down match to stuff that is the same behind the cursor
bind '"\e[A"':history-search-backward
bind '"\e[B"':history-search-forward
function beast () {
git rm *.DS_Store
git add .;
git commit -m "$@";
git pull;
};
function rage () {
git rm *.DS_Store
git add .;
git difftool HEAD;
git commit -m "$@";
git pull;
git push;
};
function push () {
git push "$@";
}
# To encrypt a file:
# openssl des3 -salt -in file.log -out file.des3
alias encrypt="openssl des3 -salt"
# To Decrypt:
# openssl des3 -d -salt -in file.des3 -out file.txt
# decrypt -in file.des3 -out file.txt
alias decrypt="openssl des3 -d -salt"
function gstats {
# awesome work from https://github.com/esc/git-stats
# including some modifications
if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
echo "Number of commits per author:"
git --no-pager shortlog -sn --all
AUTHORS=$( git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
LOGOPTS=""
if [ "$1" == '-w' ]; then
LOGOPTS="$LOGOPTS -w"
shift
fi
if [ "$1" == '-M' ]; then
LOGOPTS="$LOGOPTS -M"
shift
fi
if [ "$1" == '-C' ]; then
LOGOPTS="$LOGOPTS -C --find-copies-harder"
shift
fi
for a in $AUTHORS
do
echo '-------------------'
echo "Statistics for: $a"
echo -n "Number of files changed: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f3 | sort -iu | wc -l
echo -n "Number of lines added: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f1 | awk '{s+=$1} END {print s}'
echo -n "Number of lines deleted: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f2 | awk '{s+=$1} END {print s}'
echo -n "Number of merges: "
git log $LOGOPTS --all --merges --author=$a | grep -c '^commit'
done
else
echo "you're currently not in a git repository"
fi
}
function myip {
res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+')
echo "$res"
}
# set fancy prompt
if [ -f "$HOME/.bash_ps" ]; then
. "$HOME/.bash_ps"
fi
dirlength() {
echo -n ${PWD/#$HOME} | wc -c
}
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
tarball () {
tar -zcvf "$1.tar.gz" $1
}
mov_to_mp4 () {
ffmpeg -i $1.mov -qscale 0 $1.mp4
}
runforever () {
while true; do
$@
echo "Process Died... RESTARTING"
sleep 5
done
}
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
function portkill () {
pid=$(lsof -i:$1 -t);
if [ "$pid" != "" ]; then
# First try to kill the process gently. Then KILL it if it doesnt die
kill -TERM $pid || kill -KILL $pid
fi
}
#function pods () {
# kubectl get pods --namespace @(a[2] if len(a) > 2 else "default") -l @("app=" + a[0] + ",release=" + a[1]) -o jsonpath="{.items[0].metadata.name}"
#}