Mercurial > hg > config
comparison .bashrc @ 71:3d111401010f
add a function to view the files in a diff
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 26 May 2010 10:15:35 -0700 |
parents | a791d862148c |
children | 84ffa220796a |
comparison
equal
deleted
inserted
replaced
70:a9110cc98d94 | 71:3d111401010f |
---|---|
41 export PYTHONPATH=~/python:$PYTHONPATH | 41 export PYTHONPATH=~/python:$PYTHONPATH |
42 | 42 |
43 | 43 |
44 # functions | 44 # functions |
45 cdwin() { | 45 cdwin() { |
46 # change directory to a window's location using its title | |
46 DIR=$(xwininfo | dictify.py xwininfo | awk '{ print $NF }' | sed 's/"//g') | 47 DIR=$(xwininfo | dictify.py xwininfo | awk '{ print $NF }' | sed 's/"//g') |
47 DIR=${DIR/\~/$HOME} | 48 DIR=${DIR/\~/$HOME} |
48 cd $DIR | 49 cd $DIR |
49 } | 50 } |
50 | 51 |
51 eend() { | 52 eend() { |
53 # edit the end of a file with emacs | |
52 FILE=$1 | 54 FILE=$1 |
53 shift | 55 shift |
54 emacs +`wc -l "$FILE"` $@ | 56 emacs +`wc -l "$FILE"` $@ |
55 } | 57 } |
56 | 58 |
165 cat $FILE | 167 cat $FILE |
166 rm $FILE | 168 rm $FILE |
167 } | 169 } |
168 | 170 |
169 swap() { | 171 swap() { |
172 # swap two files | |
170 if [ "$#" != "2" ] | 173 if [ "$#" != "2" ] |
171 then | 174 then |
172 echo "Usage: $FUNCNAME <first_arg> <second_arg>" | 175 echo "Usage: $FUNCNAME <first_arg> <second_arg>" |
173 return | 176 return |
174 fi | 177 fi |
193 mv `basename $2` `basename $1` | 196 mv `basename $2` `basename $1` |
194 mv $NEWNAME `basename $2` | 197 mv $NEWNAME `basename $2` |
195 } | 198 } |
196 | 199 |
197 isrunning() { | 200 isrunning() { |
201 # is a process running? (by name) | |
198 for i in "$@" | 202 for i in "$@" |
199 do | 203 do |
200 ps axwww | grep "$i" | grep -v 'grep' | 204 ps axwww | grep "$i" | grep -v 'grep' |
201 done | sort | uniq | 205 done | sort | uniq |
202 | 206 |
203 } | 207 } |
204 | 208 |
205 killbyname() { | 209 killbyname() { |
210 # kill a process by name | |
206 kill `isrunning "$@" | awk '{ print $1 }' | onelineit.py` | 211 kill `isrunning "$@" | awk '{ print $1 }' | onelineit.py` |
207 } | 212 } |
208 | 213 |
209 | 214 |
210 tf() { | 215 tf() { |
230 whemacs() { | 235 whemacs() { |
231 emacs -nw `which $@` | 236 emacs -nw `which $@` |
232 } | 237 } |
233 | 238 |
234 pyfile() { | 239 pyfile() { |
240 # python file name | |
235 python -c "import $1; print $1.__file__" | 241 python -c "import $1; print $1.__file__" |
236 } | 242 } |
237 | 243 |
238 svndance(){ | 244 svndance(){ |
245 # do the svn import dance! | |
239 if (( $# )) | 246 if (( $# )) |
240 then | 247 then |
241 svn import $1 | 248 svn import $1 |
242 cd .. | 249 cd .. |
243 rm -rf $OLDPWD | 250 rm -rf $OLDPWD |
246 else | 253 else |
247 return 1 | 254 return 1 |
248 fi | 255 fi |
249 } | 256 } |
250 | 257 |
258 difffiles() { | |
259 grep '^+++ ' $@ | sed 's/+++ b\///' | |
260 } | |
261 | |
251 ### include overrides for commands | 262 ### include overrides for commands |
252 source ~/.bash_overrides | 263 source ~/.bash_overrides |
253 | 264 |
254 ### regenerate fluxbox menus here for convenience | 265 ### regenerate fluxbox menus here for convenience |
255 MENU=~/web/site/programs.html | 266 MENU=~/web/site/programs.html |