Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 380 lines (337 sloc) 7.287 kB
f36c699 @derekwyatt Initial commit
authored
1 # Path to your oh-my-zsh configuration.
2 ZSH=$HOME/.oh-my-zsh
3 ZSH_THEME="gnzh"
4 # Set to this to use case-sensitive completion
5 # CASE_SENSITIVE="true"
6
7 # Comment this out to disable weekly auto-update checks
8 # DISABLE_AUTO_UPDATE="true"
9
10 # Uncomment following line if you want to disable colors in ls
11 # DISABLE_LS_COLORS="true"
12
13 # Uncomment following line if you want to disable autosetting terminal title.
14 # DISABLE_AUTO_TITLE="true"
15
16 # Uncomment following line if you want red dots to be displayed while waiting for completion
17 COMPLETION_WAITING_DOTS="true"
18
ffe07f7 @derekwyatt Aha! Getting rid of the vi-mode plugin is better for vi mode than not…
authored
19 plugins=(git)
f36c699 @derekwyatt Initial commit
authored
20
ffe07f7 @derekwyatt Aha! Getting rid of the vi-mode plugin is better for vi mode than not…
authored
21 source $ZSH/oh-my-zsh.sh
22 bindkey -v
f36c699 @derekwyatt Initial commit
authored
23 bindkey -M viins 'jj' vi-cmd-mode
24
25 if [ $(uname) = Darwin ]; then
26 export PATH=.:~/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
27 else
28 export PATH=.:buildutil:/home/dwyatt/local/bin:/home/dwyatt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/qnx650/host/linux/x86/usr/bin:/etc/qnx/bin
29 fi
30
31 export GPGKEY=B2F6D883
32 export GPG_TTY=$(tty)
33
34 export EDITOR=/usr/local/bin/vim
35 export JAVA_HOME=/usr/local/jdk
36
37 if which dircolors > /dev/null; then
38 test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
39 alias ls='ls --color=auto -F'
40 alias grep='grep --color=auto'
41 alias fgrep='fgrep --color=auto'
42 alias egrep='egrep --color=auto'
43 fi
44
45 function gg
46 {
47 if uname | grep -q Darwin; then
48 mvim --remote-silent $@
49 else
50 gvim --remote-silent $@
51 fi
52 }
53
54 function eecho
55 {
56 echo $@ 1>&2
57 }
58
59 function findWithSpec
60 {
61 local dirs=
62 local egrepopts="-v '\\.sw[po]\\$|/\\.git/|^\\.git/'"
63 local nullprint=
64 while [[ $# != 0 ]];
65 do
66 if [[ "$1" == "-Z" ]]; then
67 egrepopts="-Zz $egrepopts"
68 nullprint="-print0"
69 shift
70 elif [[ -d "$1" ]]; then
71 dirs="$dirs '$1'"
72 shift
73 else
74 break
75 fi
76 done
77 if [[ -z "$dirs" ]]; then
78 dirs=.
79 fi
80 eval "find $dirs $nullprint $@ | egrep $egrepopts"
81 }
82
83 function findsrc
84 {
85 findWithSpec "$@" '-name \*.java -o -name \*.scala -o -name Makefile -o -name \*.h -o -name \*.cpp -o -name \*.c'
86 }
87 alias findsrcz="findsrc -Z"
88
89 function findj
90 {
91 findWithSpec "$@" '-name \*.java'
92 }
93 alias findjz="findj -Z"
94
95 function finds
96 {
97 findWithSpec "$@" '-name \*.scala'
98 }
99 alias findsz="finds -Z"
100
101 function findsj
102 {
103 (finds "$@"; findj "$@")
104 }
105 alias findsjz="findsj -Z"
106
107 function findh
108 {
109 findWithSpec "$@" '-name \*.h -o -name \*.hpp'
110 }
111 alias findhz="findh -Z"
112
113 function findc
114 {
115 findWithSpec "$@" '-name \*.cpp -o -name \*.c'
116 }
117 alias findcz="findc -Z"
118
119 function findch
120 {
121 (findc "$@"; findh "$@")
122 }
123 alias findchz="findch -Z"
124
125 function findf
126 {
127 findWithSpec "$@" "-type f"
128 }
129 alias findfz="findf -Z"
130
131 function findm
132 {
133 findWithSpec "$@" "-name Makefile"
134 }
135 alias findmz="findm -Z"
136
137 alias f=findWithSpec
138
139 function findClass
140 {
141 local pattern="${1-}"
142 if [ -z "$pattern" ]; then
143 eecho "No pattern supplied" 1>&2
144 return 1
145 fi
146 echo $CLASSPATH | tr ':' '\n' | grep -v '^ *$' | \
147 while read entry
148 do
149 echo "====== $entry ======"
150 if [ "${entry%.jar}" != "$entry" ]; then
151 if [ -f "$entry" ]; then
152 jar tf "$entry" | egrep $pattern
153 fi
154 elif [ -d "$entry" ]; then
155 find "$entry" | egrep -i $pattern
156 fi
157 done
158 }
159
160 function ff
161 {
162 if [ $# = 0 ]; then
163 eecho "usage: ff <file>" 1>&2
164 return 1
165 fi
166 if [ -d "$1" ]; then
167 eecho "That's a directory, dumbass." 1>&2
168 return 1
169 elif [ "${1%/*}" = "$1" ]; then
170 firefox -new-tab "file://$(pwd)/$1"
171 else
172 "cd" "${1%/*}"
173 local dir="$(pwd)"
174 "cd" - >/dev/null
175 firefox -new-tab "file://$dir/${1##*/}"
176 fi
177 return 0
178 }
179
180 function gitnotify
181 {
182 if [[ ! -d .git ]]; then
183 eecho "You're not in a git repository dumbass"
184 return 1
185 fi
186 local proj="$(basename $(pwd))"
187 local commit=$(git log -1 | head -1 | awk '{print $2}')
188 local url="$(printf 'http://gitweb.rim.net/?p=users/dwyatt/%s.git;a=commit;h=%s' $proj $commit)"
189 for user in $*
190 do
191 local email=
192 case $user in
193 ron) email=ropuri@rim.com
194 ;;
195 derek) email=dwyatt@rim.com
196 ;;
197 esac
198 if [[ -n $email ]]; then
199 ssmtp $email <<EOH
200 To: $email
201 From: dwyatt@rim.com
202 Subject: Commit on $proj
203 Content-Type: text/html; charset="us-ascii"
204 <html>
205 <a href='$url'>$commit</a>
206 </html>
207 EOH
208 eecho "sent notification to $user ($email)"
209 fi
210 done
211 }
212
213 # Assorted
214 alias swps='find . -name .\*.sw[op]'
215 alias rmstd='xargs rm -vf'
216 alias xag='xargs -0 egrep'
217
218 alias open=gnome-open
219 alias sc=screen
220 alias scl="screen -list"
221
222 function eecho
223 {
224 echo $@ 1>&2
225 }
226
227 function pd
228 {
229 local dirname="${1-}"
230 local firstdir seconddir ret p oldDIRSTACK
231
232 if [ "$dirname" = "" ]; then
233 firstdir=$(pwd)
234 if [ ${#DS[*]} = 0 ]; then
235 eecho "Stack is empty. Cannot swap."
236 return 1
237 fi
238 seconddir=$(popStack)
239 pushStack "$firstdir"
240 "cd" "$seconddir"
241 ret=$?
242 return $ret
243 else
244 if [ -d "$dirname" ]; then
245 if [ "$dirname" != '.' ]; then
246 pushStack "$(pwd)"
247 fi
248 "cd" "$dirname"
249 ret=$?
250 return $ret
251 else
252 eecho "zsh: $dirname: not found"
253 return 1
254 fi
255 fi
256 }
257
258 function cd_
259 {
260 local ret=0
261
262 if [ $# = 0 ]; then
263 pd "$HOME"
264 ret=$?
265 elif [[ $# == 1 && "$1" == "-" ]]; then
266 pd
267 ret=$?
268 elif [ $# -gt 1 ]; then
269 local from="$1"
270 local to="$2"
271 local c=0
272 local path=
273 local x=$(pwd)
274 local numberOfFroms=$(echo $x | tr '/' '\n' | grep "^$from$" | wc -l)
275 while [ $c -lt $numberOfFroms ]
276 do
277 path=
278 local subc=$c
279 local tokencount=0
280 for subdir in $(echo $x | tr '/' '\n' | tail -n +2)
281 do
282 if [[ "$subdir" == "$from" ]]; then
283 if [ $subc -eq $tokencount ]; then
284 path="$path/$to"
285 subc=$((subc+1))
286 else
287 path="$path/$from"
288 tokencount=$((tokencount+1))
289 fi
290 else
291 path="$path/$subdir"
292 fi
293 done
294 if [ -d "$path" ]; then
295 break
296 fi
297 c=$((c=c+1))
298 done
299 if [ "$path" == "$x" ]; then
300 eecho "Bad substitution"
301 ret=1
302 else
303 pd "$path"
304 ret=$?
305 fi
306 else
307 pd "$1"
308 ret=$?
309 fi
310
311 return $ret
312 }
313
314 function popStack
315 {
316 if [[ ${#DS[*]} == 0 ]]; then
317 eecho "Cannot pop stack. No elements to pop."
318 return 1
319 fi
320 local retv="${DS[1]}"
321 set -A DS ${DS[2,-1]}
322
323 echo $retv
324 }
325
326 function pushStack
327 {
328 set -A DS "$1" ${DS[1,-1]}
329 }
330
331 function ss
332 {
333 local c=1
334 for f in $DS
335 do
336 if (( ${#f} > 100 )); then
337 x="...$(echo $f | cut -c$((${#f}-100))-)"
338 else
339 x=$f
340 fi
341 echo "$c) $x"
342 ((c=c+1))
343 done
344 }
345
346 function csd
347 {
348 local num="${1-}"
349
350 if ! echo "$num" | grep -q '^[0-9][0-9]*$'; then
351 c=1
352 re=$num
353 num=1
354 while [ "$c" -le "${#DS[*]}" ]
355 do
356 if echo "${DS[$c]}" | grep -q $re; then
357 num=$c
358 break
359 fi
360 ((c=c+1))
361 done
362 fi
363 if [ $num = 0 ]; then
364 eecho "usage: csd <number greater than 0 | regex>"
365 return 1
366 elif [ $num -gt ${#DS[*]} ]; then
367 eecho $num is beyond the stack size.
368 return 1
369 else
370 local dir=${DS[$num]}
371 set -A DS ${DS[1,$((num-1))]} ${DS[$((num+1)),-1]}
372 cd_ "$dir"
373 return $?
374 fi
375 }
376
377 alias cd=cd_
af616e0 @derekwyatt Added sourcing of local configurations
authored
378
379 test -f ~/.zshrc_local && . ~/.zshrc_local
Something went wrong with that request. Please try again.