Mercurial > hg > config
annotate .bashrc @ 534:6ee5d5cca949
.bashrc
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 26 Sep 2013 02:19:42 -0700 |
parents | e1aa8835edb7 |
children | 2c1543b5c78f |
rev | line source |
---|---|
334
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
1 #!/bin/bash |
379 | 2 |
334
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
3 ### bash rc file ### |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
4 |
379 | 5 # source the profile, if it exists |
332 | 6 PROFILE=/etc/profile |
7 if [ -e "${PROFILE}" ] | |
8 then | |
9 . "${PROFILE}" | |
10 fi | |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
11 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
12 # Test for an interactive shell. There is no need to set anything |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
13 # past this point for scp and rcp, and it's important to refrain from |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
14 # outputting anything in those cases. |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
15 if [[ $- != *i* ]] ; then |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
16 # Shell is non-interactive. Be done now! |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
17 return |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
18 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
19 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
20 # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
21 if [[ -f ~/.dir_colors ]] ; then |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
22 eval $(dircolors -b ~/.dir_colors) |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
23 elif [[ -f /etc/DIR_COLORS ]] ; then |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
24 eval $(dircolors -b /etc/DIR_COLORS) |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
25 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
26 |
67
a791d862148c
add a default MOZCONFIG variable -- BE CAREFUL!
Jeff Hammel <jhammel@mozilla.com>
parents:
66
diff
changeset
|
27 # variables |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
28 export BROWSER=$(which firefox) |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
29 export CLICOLOR=1 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
30 export EDITOR='emacs -nw' |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
31 export JS_EDITLINE=1 |
510 | 32 export JS_EDITLINE=1 |
33 | |
34 # mozilla env vairables | |
171
0110a435d2ce
use a directory for mozconfigs
Jeff Hammel <jhammel@mozilla.com>
parents:
169
diff
changeset
|
35 export MOZCONFIG=~/mozilla/mozconfigs/mozconfig |
88
24f933c9d97f
add an xpcshell alias, silly ubuntu installed version is fuxored
Jeff Hammel <jhammel@mozilla.com>
parents:
86
diff
changeset
|
36 export MOZSOURCE=~/mozilla/src/mozilla-central |
24f933c9d97f
add an xpcshell alias, silly ubuntu installed version is fuxored
Jeff Hammel <jhammel@mozilla.com>
parents:
86
diff
changeset
|
37 export MOZOBJ=~/mozilla/src/obj-browser |
510 | 38 unsetmozenv() { |
39 unset MOZCONFIG | |
40 unset MOZSOURCE | |
41 unset MOZOBJ | |
42 } | |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
43 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
44 # aliases |
250 | 45 alias awd="python -c 'import os; print os.path.realpath(\".\")'" |
514 | 46 alias currentpatch='echo `hg root`/.hg/patches/`hg qapp -v | tail -n 1 | cut -f 3 -d " "`' |
246
d9b8d176c449
add a thing to get the full path to current patch and start organizing aliases
Jeff Hammel <jhammel@mozilla.com>
parents:
241
diff
changeset
|
47 alias datestamp='date +%Y%m%d%H%M%S' |
250 | 48 alias distribute='python setup.py egg_info -RDb "" sdist register upload' |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
49 alias grep='grep --colour=auto' |
246
d9b8d176c449
add a thing to get the full path to current patch and start organizing aliases
Jeff Hammel <jhammel@mozilla.com>
parents:
241
diff
changeset
|
50 alias ls='ls --color=auto' |
431 | 51 alias maze='python <(curl https://raw.github.com/joewing/maze/master/maze.py 2> /dev/null)' |
379 | 52 alias patch='patch --reject-file=-' |
250 | 53 alias random="python -c 'import sys, random; foo = sys.argv[1:]; random.shuffle(foo); print \" \".join(foo)'" |
431 | 54 alias straceff="attach.py firefox --kill" |
314 | 55 alias weekstamp="date --date=\"$((`date '+%u'`-1)) days ago\" '+%b %d'" |
250 | 56 alias wget='wget --no-check-certificate' |
88
24f933c9d97f
add an xpcshell alias, silly ubuntu installed version is fuxored
Jeff Hammel <jhammel@mozilla.com>
parents:
86
diff
changeset
|
57 alias xpcshell="LD_LIBRARY_PATH=${MOZOBJ}/dist/bin ${MOZOBJ}/dist/bin/xpcshell" |
241 | 58 |
59 # bzconsole aliases for filing bugs | |
60 alias mozbase-bug="bz new Mozbase --cc ':wlach'" | |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
61 alias mozbuild-bug="bz new --product Core 'Build Config' --cc ':gps'" |
215
bf4eb11045cc
front end for mozharness bugs
Jeff Hammel <jhammel@mozilla.com>
parents:
171
diff
changeset
|
62 alias mozharness-bug="bz new 'Release Engineering: Automation (General)' --cc ':aki' --whiteboard 'mozharness'" |
241 | 63 alias releng-bug="bz new 'Release Engineering: Automation (General)'" |
217 | 64 alias talos-bug="bz new Talos --cc ':jmaher' --cc ':BYK'" |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
65 |
66 | 66 # PROMPT |
119 | 67 PS1='│' |
68 PS2='.' | |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
69 PROMPT_COMMAND='echo -ne "\033]0;${SSH_CLIENT/*/$HOSTNAME:}${PWD/~/~}\007"' |
415 | 70 # Alt: PS2='☰', PS1='🎩 ' |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
71 |
66 | 72 # PATHs |
529 | 73 export PATH=~/firefox:~/bin:~/bin/mozilla:~/python:$PATH:/usr/sbin:/usr/games/bin:~/virtualenv:~/silvermirror/bin:~/smartopen/bin:~/k0s/bin:~/docs/project/ims/workflow |
169
ab2fc6222f94
add virtualenv to the PYTHONPATH
Jeff Hammel <jhammel@mozilla.com>
parents:
167
diff
changeset
|
74 export PYTHONPATH=~/python:$PYTHONPATH:~/virtualenv |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
75 |
84 | 76 ### functions |
77 | |
349 | 78 lspath() { |
79 python -c 'import os; print "\n".join(os.environ["PATH"].split(os.path.pathsep))' | |
80 } | |
81 | |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
82 apply-patch() { |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
83 # apply a patch |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
84 # TODO: |
331 | 85 # - rewrite in python! |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
86 # - extract this general pattern as a bash "decorator" like `lsdiff` in .bash_overrides |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
87 # - right now level=1; make this configurable (somehow) |
331 | 88 |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
89 if (( ! $# )) |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
90 then |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
91 echo "No patch supplied" |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
92 return 1 |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
93 fi |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
94 |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
95 for patch in $@ |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
96 do |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
97 if expr "$1" : 'http[s]\?://.*' &> /dev/null |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
98 then |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
99 IS_URL="true" |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
100 else |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
101 IS__URL="false" |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
102 fi |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
103 |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
104 if [[ ${IS_URL} == "true" ]] |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
105 then |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
106 if curl --location "${patch}" 2> /dev/null | (command patch -p1 --dry-run &> /dev/null) |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
107 then |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
108 curl --location "${patch}" 2> /dev/null | command patch -p1 |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
109 continue |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
110 else |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
111 echo "curl --location ${patch} 2> /dev/null | command patch -p1 --dry-run" |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
112 curl --location "${patch}" 2> /dev/null | command patch -p1 --dry-run |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
113 return $? |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
114 fi |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
115 else |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
116 if patch -p1 --dry-run < ${patch} |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
117 then |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
118 patch -p1 < ${patch} |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
119 continue |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
120 else |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
121 echo "patch -p1 --dry-run < ${patch}" |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
122 patch -p1 --dry-run < ${patch} |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
123 return $? |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
124 fi |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
125 fi |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
126 done |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
127 } |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
128 |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
129 cdwin() { |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
130 # change directory to a window's location using its title, |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
131 # as that is set to the cwd by PS1 [?] |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
132 # TODO: ssh windows |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
133 DIR=$(xwininfo | dictify.py xwininfo | awk '{ print $NF }' | sed 's/"//g') |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
134 DIR=${DIR/\~/$HOME} |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
135 cd $DIR |
532 | 136 activate-nearest |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
137 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
138 |
66 | 139 function colors() { |
140 | |
141 CLR_WHITE="\033[0;37m" | |
142 CLR_WHITEBOLD="\033[1;37m" | |
143 CLR_BLACK="\033[0;30m" | |
144 CLR_GRAY="\033[1;30m" | |
145 CLR_BLUE="\033[1;34m" | |
146 CLR_BLUEBOLD="\033[0;34m" | |
147 CLR_GREEN="\033[0;32m" | |
148 CLR_GREENBOLD="\033[1;32m" | |
149 CLR_CYAN="\033[0;36m" | |
150 CLR_CYANBOLD="\033[1;36m" | |
151 CLR_RED="\033[0;31m" | |
152 CLR_REDBOLD="\033[1;31m" | |
153 CLR_PURPLE="\033[0;35m" | |
154 CLR_PURPLEBOLD="\033[1;35m" | |
155 CLR_YELLOW="\033[0;33m" | |
156 CLR_YELLOWBOLD="\033[1;33m" | |
157 CLR_NOTHING="\033[0m" | |
158 } | |
159 colors | |
160 | |
418 | 161 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
162 eend() { |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
163 # edit the end of a file with emacs |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
164 FILE=$1 |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
165 shift |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
166 emacs +`wc -l "$FILE"` $@ |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
167 } |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
168 |
534 | 169 ### find functionality |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
170 |
303
266d6b337373
still doesnt work but what the fuck
Jeff Hammel <jhammel@mozilla.com>
parents:
296
diff
changeset
|
171 EXCLUDES="(\.svn)|(\.mo$)|(\.po$)|(\.pyc$)|(\.hg$)|(\.git$)" |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
172 ff() { |
304
7ed290454f50
random cleanup but not much
Jeff Hammel <jhammel@mozilla.com>
parents:
303
diff
changeset
|
173 # nice fast find function |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
174 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
175 if (( $# < 2 )) |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
176 then |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
177 FILENAME='*' # default -- look in all files |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
178 else |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
179 FILENAME=$2 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
180 fi |
76 | 181 CMD='command find -L $PWD -iname "${FILENAME}" -print0 2> /dev/null | xargs -r0 grep -il "$1" 2> /dev/null | egrep -v "${EXCLUDES}" 2> /dev/null' |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
182 # echo $CMD |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
183 eval $CMD |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
184 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
185 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
186 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
187 chainff() { |
304
7ed290454f50
random cleanup but not much
Jeff Hammel <jhammel@mozilla.com>
parents:
303
diff
changeset
|
188 # chained fast find |
7ed290454f50
random cleanup but not much
Jeff Hammel <jhammel@mozilla.com>
parents:
303
diff
changeset
|
189 |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
190 if (( $# < 2 )) |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
191 then |
304
7ed290454f50
random cleanup but not much
Jeff Hammel <jhammel@mozilla.com>
parents:
303
diff
changeset
|
192 return 1 # bad invocation |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
193 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
194 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
195 RESULTS=`ff "$2" "$1"` |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
196 shift 2 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
197 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
198 for i in $RESULTS |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
199 do |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
200 for arg in $@ |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
201 do |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
202 if grep -il "$arg" "$i" &> /dev/null |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
203 then |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
204 touch /dev/null |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
205 else |
260
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
206 i="" |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
207 break |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
208 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
209 done |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
210 if [ -n "$i" ] |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
211 then |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
212 echo $i |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
213 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
214 done |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
215 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
216 |
304
7ed290454f50
random cleanup but not much
Jeff Hammel <jhammel@mozilla.com>
parents:
303
diff
changeset
|
217 |
66 | 218 cff () { |
304
7ed290454f50
random cleanup but not much
Jeff Hammel <jhammel@mozilla.com>
parents:
303
diff
changeset
|
219 # contextual fastfind |
66 | 220 if (( $# < 2 )); then |
221 local FILENAME='*' # default -- look in all files | |
222 else | |
223 local FILENAME=$2 | |
224 fi | |
225 | |
226 for i in `ff "$1" "$FILENAME"`; do | |
227 echo -e "$CLR_GREEN--->>> ""$CLR_YELLOWBOLD""$i""$CLR_NOTHING" : | |
228 grep --color=auto -i -n -C 3 "$1" $i | |
229 done | |
230 | |
260
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
231 } |
66 | 232 |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
233 tmpfile() { |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
234 # make a temporary file if `tempfile` not available |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
235 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
236 if [ "$#" == "0" ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
237 then |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
238 args="tmp" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
239 else |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
240 args=$@ |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
241 fi |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
242 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
243 for i in $args |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
244 do |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
245 NEWNAME=${i}.$RANDOM |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
246 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
247 while [ -e $NEWNAME ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
248 do |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
249 NEWNAME=${NEWNAME}.tmp |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
250 done |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
251 echo "$NEWNAME" |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
252 done |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
253 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
254 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
255 edpe() { |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
256 # edit and pipe the buffer to stdout |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
257 FILE=`tmpfile` |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
258 $EDITOR $FILE |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
259 cat $FILE |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
260 rm $FILE |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
261 } |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
262 |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
263 isrunning() { |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
264 # is a process running? (by name) |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
265 # see also: talos for a better version |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
266 for i in "$@" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
267 do |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
268 ps axwww | grep "$i" | grep -v 'grep' |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
269 done | sort | uniq |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
270 |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
271 } |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
272 |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
273 killbyname() { |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
274 # kill a process by name |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
275 kill `isrunning "$@" | awk '{ print $1 }' | onelineit.py` |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
276 } |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
277 |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
278 fn() { |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
279 # full name |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
280 python -c "import os; print os.path.realpath('$*')" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
281 } |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
282 |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
283 swap() { |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
284 # swap two files |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
285 if [ "$#" != "2" ] |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
286 then |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
287 echo "Usage: $FUNCNAME <file1> <file2>" |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
288 return |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
289 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
290 for i in "$1" "$2" |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
291 do |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
292 if [ ! -w "$i" ] |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
293 then |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
294 echo "$FUNCNAME: Can't move $i" |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
295 return 1 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
296 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
297 done |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
298 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
299 NEWNAME=`basename $1`.$RANDOM |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
300 while [ -e $NEWNAME ] |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
301 do |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
302 NEWNAME=${NEWNAME}.tmp |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
303 echo "$NEWNAME" |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
304 done |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
305 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
306 mv "$1" "$NEWNAME" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
307 mv "$2" "$1" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
308 mv "$NEWNAME" "$2" |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
309 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
310 |
330 | 311 buffer() { |
312 # temporary buffer with cat and /dev/null | |
313 cat > /dev/null | |
314 } | |
315 | |
309 | 316 ### `which` commands |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
317 |
309 | 318 realwhich() { |
319 # which -> real paths | |
320 command which $@ | while read line | |
321 do | |
322 python -c "import os; print os.path.realpath('${line}')" | |
323 done | |
324 } | |
325 | |
310
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
326 whview() { |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
327 # which view |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
328 less `realwhich $@` |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
329 } |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
330 |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
331 whemacs() { |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
332 # which emacs |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
333 emacs -nw `realwhich $@` |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
334 } |
a6cd6900419e
whview and whemacs use realwhich
Jeff Hammel <jhammel@mozilla.com>
parents:
309
diff
changeset
|
335 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
336 ### functions for python |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
337 |
305
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
338 pyfile() { |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
339 # python file path |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
340 python -c "import $1; print $1.__file__" |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
341 } |
fac01a1bcedf
add an apply-patch function
Jeff Hammel <jhammel@mozilla.com>
parents:
304
diff
changeset
|
342 |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
343 setup-all() { |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
344 # setup all for development |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
345 # TODO: flowerbed? |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
346 for i in * |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
347 do |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
348 if [ -e "${i}/setup.py" ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
349 then |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
350 cd "${i}" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
351 python setup.py develop |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
352 cd .. |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
353 fi |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
354 done |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
355 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
356 |
531 | 357 nearest-venv() { |
358 if [[ "$#" == "0" ]] | |
359 then | |
360 directory=$PWD | |
361 else | |
362 directory=$1 | |
363 fi | |
364 directory=$(python -c "import os; print os.path.abspath('${directory}')") | |
365 | |
366 while [[ "${directory}" != "/" ]] | |
367 do | |
368 activate="${directory}/bin/activate" | |
369 if [ -e "${activate}" ] | |
370 then | |
371 echo ${directory} | |
372 return 0 | |
373 fi | |
374 | |
375 directory=$(dirname ${directory}) | |
376 | |
377 done | |
378 return 1 | |
379 } | |
380 | |
381 activate-nearest() { | |
382 nearest=$(nearest-venv) | |
383 activate=${nearest}/bin/activate | |
384 if [ -e "${activate}" ] | |
385 then | |
386 . ${activate} | |
387 fi | |
388 } | |
389 | |
296 | 390 recreate-venv() { |
391 # recreate a virtualenv | |
392 VIRTUALENV="virtualenv.py" | |
334
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
393 if ! which ${VIRTUALENV} |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
394 then |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
395 return 1 |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
396 fi |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
397 VENV_PATH=$(which ${VIRTUALENV} &> /dev/null) |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
398 |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
399 # update virtualenv if possible |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
400 DIRNAME=$(dirname ${VENV_PATH}) |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
401 if [ -d "${DIRNAME}/.git" ] |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
402 then |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
403 cd "${DIRNAME}" |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
404 git pull |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
405 cd -- |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
406 fi |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
407 |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
408 |
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
409 # for each virtualenv given... |
296 | 410 for i in $@ |
411 do | |
334
5b67dd5ce0ba
update virtualenv before upgrading
Jeff Hammel <jhammel@mozilla.com>
parents:
332
diff
changeset
|
412 # ...recreate it... |
296 | 413 ${VIRTUALENV} --clear "${i}" |
414 | |
415 SRCDIR="${i}"/src | |
416 if [ -d "${SRCDIR}" ] | |
417 then | |
418 . "${i}/bin/activate" | |
419 OLDPWD=${PWD} | |
420 cd "${SRCDIR}" | |
421 for j in * | |
422 do | |
423 if [ -e "${j}"/setup.py ] | |
424 then | |
425 cd "${j}" | |
426 python setup.py develop | |
427 cd .. | |
428 fi | |
429 done | |
430 cd "${OLDPWD}" | |
431 fi | |
432 done | |
433 } | |
434 | |
260
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
435 ### functions for version control systems |
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
436 |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
437 svndance(){ |
71
3d111401010f
add a function to view the files in a diff
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
438 # do the svn import dance! |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
439 if (( $# )) |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
440 then |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
441 svn import $1 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
442 cd .. |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
443 rm -rf $OLDPWD |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
444 svn co $1 $OLDPWD |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
445 cd $OLDPWD |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
446 else |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
447 return 1 |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
448 fi |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
449 } |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
450 |
71
3d111401010f
add a function to view the files in a diff
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
451 difffiles() { |
534 | 452 # which files are diffed; could use `lsdiff` |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
453 grep '^+++ ' $@ | sed 's/+++ b\///' |
71
3d111401010f
add a function to view the files in a diff
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
454 } |
3d111401010f
add a function to view the files in a diff
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
455 |
534 | 456 git-diff-master() { |
457 # differences of a git repository with master | |
458 git diff $(git merge-base HEAD master) | |
459 } | |
460 | |
461 git-diff-total() { | |
462 # diff of both added + modified files | |
463 combinediff <(git diff) <(git diff --cached) | |
464 } | |
465 | |
260
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
466 hg-update-all() { |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
467 # update all hg repositories in the current directory |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
468 for i in *; |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
469 do |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
470 if [ -e $i/.hg ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
471 then |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
472 cd $i |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
473 hg pull |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
474 hg update |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
475 cd - |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
476 fi |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
477 done |
84 | 478 } |
479 | |
110
bf567a0e8fef
add a hg-qcommit that does the right thing
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
480 hg-qcommit() { |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
481 message=$1 |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
482 hg qrefresh |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
483 if [ -z "${message}" ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
484 then |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
485 hg qcommit |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
486 else |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
487 hg qcommit -m "${message}" |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
488 fi |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
489 hgroot=$(hg root) |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
490 patches=${hgroot}/.hg/patches/ |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
491 if [ -e ${patches}.hg ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
492 then |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
493 cd ${patches} |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
494 hg push |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
495 fi |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
496 cd - |
110
bf567a0e8fef
add a hg-qcommit that does the right thing
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
497 } |
bf567a0e8fef
add a hg-qcommit that does the right thing
Jeff Hammel <jhammel@mozilla.com>
parents:
103
diff
changeset
|
498 |
89
dfda4f7d4db4
add a command to generate those hgrc files i always need
Jeff Hammel <jhammel@mozilla.com>
parents:
88
diff
changeset
|
499 |
260
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
500 ### functions for web content |
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
501 |
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
502 blog-file() { |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
503 echo "$HOME/web/blog/k0s/entries/public/$1" |
260
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
504 } |
eacc4c5ed628
add an alias for mozbuild bugs and cleanup a bit
Jeff Hammel <jhammel@mozilla.com>
parents:
250
diff
changeset
|
505 |
330 | 506 ### |
507 | |
101 | 508 flatten() { |
509 directory=$PWD | |
510 if [ "$#" == "1" ] | |
511 then | |
512 directory=$1 | |
513 fi | |
514 cd $directory | |
515 unset find # don't use the alias | |
102 | 516 find . -name '*' -type f | sed 's/.\///' | while read line |
101 | 517 do |
518 filename=$(echo $line | sed 's/\//-/g') | |
519 mv "${line}" "${filename}" | |
520 done | |
521 for i in * | |
522 do | |
523 if [ -d $i ] | |
524 then | |
525 rm -rf "${i}" | |
526 fi | |
527 done | |
528 } | |
529 | |
103
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
530 filehandles() { |
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
531 TMPFILE=$(tmpfile) |
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
532 ps -e|grep -v TTY|awk {'print "echo -n \"Process: "$4"\tPID: "$1"\tNumber of FH: \"; lsof -p "$1"|wc -l"'} > ${TMPFILE} |
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
533 . ${TMPFILE} | sort |
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
534 rm ${TMPFILE} |
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
535 } |
e841c419199e
add process command to get filehandles
Jeff Hammel <jhammel@mozilla.com>
parents:
102
diff
changeset
|
536 |
167
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
537 quotemail() { |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
538 |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
539 command='s/^/> /' |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
540 inplace="" |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
541 if [ "$#" == "2" ] |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
542 then |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
543 inplace="-i" |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
544 fi |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
545 |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
546 sed ${inplace} "${command}" "$1" |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
547 |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
548 } |
842e1fca024a
add a quotemail function for quoting mail
Jeff Hammel <jhammel@mozilla.com>
parents:
147
diff
changeset
|
549 |
317 | 550 rmktmp() { |
551 | |
552 TMPDIR=~/tmp | |
553 if [ -e ${TMPDIR} ] | |
554 then | |
555 rm -rf ${TMPDIR} | |
556 fi | |
557 mkdir ${TMPDIR} | |
558 cd ${TMPDIR} | |
559 pwd | |
560 | |
561 } | |
562 | |
0
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
563 ### include overrides for commands |
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
564 source ~/.bash_overrides |
47
a0636527f809
regenerate fluxbox menus on shell
Jeff Hammel <k0scist@gmail.com>
parents:
19
diff
changeset
|
565 |
a0636527f809
regenerate fluxbox menus on shell
Jeff Hammel <k0scist@gmail.com>
parents:
19
diff
changeset
|
566 ### regenerate fluxbox menus here for convenience |
531 | 567 if type deactivate &> /dev/null |
568 then | |
569 deactivate | |
570 fi | |
47
a0636527f809
regenerate fluxbox menus on shell
Jeff Hammel <k0scist@gmail.com>
parents:
19
diff
changeset
|
571 MENU=~/web/site/programs.html |
237
b33d0c78132c
move menu regeneration to its own function
Jeff Hammel <jhammel@mozilla.com>
parents:
224
diff
changeset
|
572 regeneratefluxmenu() { |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
573 if [ -e $MENU ] |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
574 then |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
575 # XXX could be safer |
303
266d6b337373
still doesnt work but what the fuck
Jeff Hammel <jhammel@mozilla.com>
parents:
296
diff
changeset
|
576 # XXX ...along with the fluxbox menu option o_O |
295
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
577 html2flux.py $MENU > ~/.fluxbox/applications |
e2564dd51334
slowly slowly, step by step...
Jeff Hammel <jhammel@mozilla.com>
parents:
279
diff
changeset
|
578 fi |
237
b33d0c78132c
move menu regeneration to its own function
Jeff Hammel <jhammel@mozilla.com>
parents:
224
diff
changeset
|
579 } |
b33d0c78132c
move menu regeneration to its own function
Jeff Hammel <jhammel@mozilla.com>
parents:
224
diff
changeset
|
580 regeneratefluxmenu |