-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprofile
226 lines (190 loc) · 4.64 KB
/
profile
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
#!/bin/bash
#
# Undo stuff before sourcing anything
#
for a in l ll la; do
if alias -p | grep $a &>/dev/null; then
unalias $a &>/dev/null
fi
done
#
# Platform specific (first because some stuff in here relies on it)
#
case `uname` in
Darwin) source $HOME/.rc/profile_Darwin ;;
Linux) source $HOME/.rc/profile_Linux ;;
esac
#
# Paths etc
#
# Blue is 34m, green is 32m, red is 31m. They used to be 01;3Xm, I can't remember what 01; is for.
export PS1='\[\033[34m\]\w \[\033[31m\]$(__git_ps1 "(%s)")\n\[\033[01;32m\]> \[\033[00m\]'
export EDITOR="vim"
export SVN_LOG_EDITOR="$EDITOR"
export PATH="$HOME/local/bin:$PATH"
export PATH="$HOME/local/rc_scripts:$PATH"
export PATH="$HOME/local/depot_tools:$PATH"
export PATH="$HOME/local/npm-global/bin:$PATH"
export PATH="$HOME/goma:$PATH"
export PATH="/usr/bin:$PATH"
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
#
# General
#
fn() { find . -name "$@"; }
c() { cd -P "$@"; }
ll() { l -l "$@"; }
la() { l -A "$@"; }
lla() { l -lA "$@"; }
v() { vim -p "$@"; }
e() { vim -p $(echo $@ | sed 's/:/ +/'); }
wg() { wget --no-check-certificate -O- "$@"; }
grr() { grep -rn --color --exclude='.svn' "$@"; }
s() { screen -DR "$@"; }
prepend() { sed "s|^|$1" "$@"; }
sx() { ssh -Y "$@"; }
vl() {
file=`echo "$1" | cut -d: -f1`
line=`echo "$1" | cut -d: -f2`
v "$file" +"$line"
}
#
# Go
#
export GOPATH="$HOME/src/go"
export NOMS_VERSION_NEXT=1
cdg() {
c "$GOPATH/src"
}
#
# Quip
#
export PATH="$PATH:$HOME/android-sdk-macosx/emulator"
export PATH="$PATH:$HOME/android-sdk-macosx/tools"
export PATH="$PATH:$HOME/android-sdk-macosx/tools/bin"
export PATH="$PATH:$HOME/android-sdk-macosx/platform-tools"
export PATH="$PATH:$HOME/quip/android/tools"
export ANDROID_HOME="$HOME/android-sdk-macosx"
#
# Git
#
source "$HOME/.rc/git_completion"
complete -o default -o nospace -F _git_branch changed
complete -o default -o nospace -F _git_branch cherry-pick
complete -o default -o nospace -F _git_branch gb
complete -o default -o nospace -F _git_branch gcb
complete -o default -o nospace -F _git_checkout gch
complete -o default -o nospace -F _git_checkout gchr
complete -o default -o nospace -F _git_diff gd
complete -o default -o nospace -F _git_diff gdt
complete -o default -o nospace -F _git_diff gdno
complete -o default -o nospace -F _git_diff gdns
complete -o default -o nospace -F _git_diff gds
complete -o default -o nospace -F _git_merge_base gmb
complete -o default -o nospace -F _git_log gl
complete -o default -o nospace -F _git_rebase gr
g() { git "$@"; }
ga() { git add "$@"; }
gb() { git branch "$@"; }
gbD() {
read -p 'Are you sure? [y/N] ' -n1 READ;
if [ "$READ" == 'y' ]; then git branch -D "$@"; fi
}
gc() { git commit "$@"; }
gcaa() { gc -a --amend; }
gch() { git checkout "$@"; }
gcho() { git checkout origin/master "$@"; }
gcp() { git cherry-pick "$@"; }
gd() { git diff "$@"; }
gdno() { git diff --name-only "$@"; }
gdns() { git diff --name-status "$@"; }
gdo() { git diff origin/master "$@"; }
gds() { git diff --stat "$@"; }
gdt() { git difftool "$@"; }
gfa() { git fetch --all --verbose "$@"; }
gg() { git grep "$@"; }
gl() { git log "$@"; }
gls() { git ls-files "$@"; }
gm() { git merge "$@"; }
gmo() { git merge origin/master "$@"; }
gmb() { git merge-base "$@"; }
gp() { git pull "$@"; }
gpr() { git pull --rebase --autostash "$@"; }
gpu() { git push "$@"; }
gr() { git rebase "$@"; }
gro() { git rebase origin/master "$@"; }
gs() { git status "$@"; }
gpgp() { git push origin "$(gcb)" "$@"; }
unmerged() {
git status -s | grep '^[AUD][AUD] ' | cut -f2 -d' '
}
gC() {
gc -m "$(gcb)" "$@"
}
gcb() {
git branch | grep '^*' | cut -f2- -d' '
}
gbase() {
gmb "$(gcb)" origin/master
}
ghide() {
if [ -z "$1" ]; then
echo "ERROR: no branch(es) supplied"
return
fi
for branch in "$@"; do
gb "$branch" -m "__`date +%F`__$branch"
done
}
changed() {
base="$1"
if [ -z "$base" ]; then
base=`gbase`
fi
gdno "$base"
}
gchr() {
oldBranch="$(gcb)"
branch="$1"
if [ -z "$branch" ]; then
echo "ERROR: no branch supplied"
return
fi
gch "$branch"
gr "$oldBranch"
}
gf() {
gls "$1" "*/$1"
}
greplace() {
from="$1"
to="$2"
shift 2
for f in `gg -l "$@" "$from"`; do
echo "Replacing in $f"
sedi $SED_I_SUFFIX "s%$from%$to%g" "$f"
done
}
gclu() {
g cl upload `gbase` "$@"
}
gh() {
git for-each-ref --sort=committerdate refs/heads --format='%(refname:short)'
}
groot() {
oldpwd=`pwd`
while [ `pwd` != / ]; do
if [ -d .git ]; then
pwd
break
fi
cd ..
done
cd "$oldpwd"
}
gnb() {
gch -b "$1" --track origin/master
}
jsonp() {
python -m json.tool
}