Mercurial > hg > config
comparison .bashrc @ 295:e2564dd51334
slowly slowly, step by step...
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Sat, 11 May 2013 04:16:56 -0700 |
| parents | 19070b2af257 |
| children | ee3c1b65d6d1 |
comparison
equal
deleted
inserted
replaced
| 294:a0d830fd8a42 | 295:e2564dd51334 |
|---|---|
| 2 | 2 |
| 3 # Test for an interactive shell. There is no need to set anything | 3 # Test for an interactive shell. There is no need to set anything |
| 4 # past this point for scp and rcp, and it's important to refrain from | 4 # past this point for scp and rcp, and it's important to refrain from |
| 5 # outputting anything in those cases. | 5 # outputting anything in those cases. |
| 6 if [[ $- != *i* ]] ; then | 6 if [[ $- != *i* ]] ; then |
| 7 # Shell is non-interactive. Be done now! | 7 # Shell is non-interactive. Be done now! |
| 8 return | 8 return |
| 9 fi | 9 fi |
| 10 | 10 |
| 11 # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 | 11 # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 |
| 12 if [[ -f ~/.dir_colors ]] ; then | 12 if [[ -f ~/.dir_colors ]] ; then |
| 13 eval $(dircolors -b ~/.dir_colors) | 13 eval $(dircolors -b ~/.dir_colors) |
| 14 elif [[ -f /etc/DIR_COLORS ]] ; then | 14 elif [[ -f /etc/DIR_COLORS ]] ; then |
| 15 eval $(dircolors -b /etc/DIR_COLORS) | 15 eval $(dircolors -b /etc/DIR_COLORS) |
| 16 fi | 16 fi |
| 17 | 17 |
| 18 # variables | 18 # variables |
| 19 export BROWSER=$(which firefox) | |
| 19 export CLICOLOR=1 | 20 export CLICOLOR=1 |
| 20 export EDITOR='emacs -nw' | 21 export EDITOR='emacs -nw' |
| 22 export JS_EDITLINE=1 | |
| 21 export MOZCONFIG=~/mozilla/mozconfigs/mozconfig | 23 export MOZCONFIG=~/mozilla/mozconfigs/mozconfig |
| 22 export MOZSOURCE=~/mozilla/src/mozilla-central | 24 export MOZSOURCE=~/mozilla/src/mozilla-central |
| 23 export MOZOBJ=~/mozilla/src/obj-browser | 25 export MOZOBJ=~/mozilla/src/obj-browser |
| 24 export JS_EDITLINE=1 | |
| 25 | 26 |
| 26 # aliases | 27 # aliases |
| 27 alias awd="python -c 'import os; print os.path.realpath(\".\")'" | 28 alias awd="python -c 'import os; print os.path.realpath(\".\")'" |
| 28 alias currentpatch='echo `hg root`/.hg/patches/`hg qapp -v | head -n 1 | cut -f 3 -d " "`' | 29 alias currentpatch='echo `hg root`/.hg/patches/`hg qapp -v | head -n 1 | cut -f 3 -d " "`' |
| 29 alias datestamp='date +%Y%m%d%H%M%S' | 30 alias datestamp='date +%Y%m%d%H%M%S' |
| 30 alias distribute='python setup.py egg_info -RDb "" sdist register upload' | 31 alias distribute='python setup.py egg_info -RDb "" sdist register upload' |
| 31 alias grep='grep --colour=auto' | 32 alias grep='grep --colour=auto' |
| 32 alias ls='ls --color=auto' | 33 alias ls='ls --color=auto' |
| 33 alias random="python -c 'import sys, random; foo = sys.argv[1:]; random.shuffle(foo); print \" \".join(foo)'" | 34 alias random="python -c 'import sys, random; foo = sys.argv[1:]; random.shuffle(foo); print \" \".join(foo)'" |
| 34 alias svnst='svn st | grep -v "^\?"' | |
| 35 alias wget='wget --no-check-certificate' | 35 alias wget='wget --no-check-certificate' |
| 36 alias xpcshell="LD_LIBRARY_PATH=${MOZOBJ}/dist/bin ${MOZOBJ}/dist/bin/xpcshell" | 36 alias xpcshell="LD_LIBRARY_PATH=${MOZOBJ}/dist/bin ${MOZOBJ}/dist/bin/xpcshell" |
| 37 | 37 |
| 38 # bzconsole aliases for filing bugs | 38 # bzconsole aliases for filing bugs |
| 39 alias mozbase-bug="bz new Mozbase --cc ':wlach'" | 39 alias mozbase-bug="bz new Mozbase --cc ':wlach'" |
| 40 alias mozbuild-bug="bz new --product Core 'Build Config' --cc ':gps'" | |
| 40 alias mozharness-bug="bz new 'Release Engineering: Automation (General)' --cc ':aki' --whiteboard 'mozharness'" | 41 alias mozharness-bug="bz new 'Release Engineering: Automation (General)' --cc ':aki' --whiteboard 'mozharness'" |
| 41 alias releng-bug="bz new 'Release Engineering: Automation (General)'" | 42 alias releng-bug="bz new 'Release Engineering: Automation (General)'" |
| 42 alias talos-bug="bz new Talos --cc ':jmaher' --cc ':BYK'" | 43 alias talos-bug="bz new Talos --cc ':jmaher' --cc ':BYK'" |
| 43 alias mozbuild-bug="bz new --product Core 'Build Config' --cc ':gps'" | |
| 44 | 44 |
| 45 # PROMPT | 45 # PROMPT |
| 46 PS1='│' | 46 PS1='│' |
| 47 PS2='.' | 47 PS2='.' |
| 48 PROMPT_COMMAND='echo -ne "\033]0;${SSH_CLIENT/*/$HOSTNAME:}${PWD/~/~}\007"' | 48 PROMPT_COMMAND='echo -ne "\033]0;${SSH_CLIENT/*/$HOSTNAME:}${PWD/~/~}\007"' |
| 49 | 49 |
| 50 # PATHs | 50 # PATHs |
| 51 export PATH=~/firefox:~/bin:~/python:$PATH:/usr/sbin:/usr/games/bin | 51 export PATH=~/firefox:~/bin:~/python:$PATH:/usr/sbin:/usr/games/bin |
| 52 export PYTHONPATH=~/python:$PYTHONPATH:~/virtualenv | 52 export PYTHONPATH=~/python:$PYTHONPATH:~/virtualenv |
| 53 | 53 |
| 54 # | |
| 55 export BROWSER=$(which firefox) | |
| 56 | |
| 57 ### functions | 54 ### functions |
| 58 | 55 |
| 59 cdwin() { | 56 cdwin() { |
| 60 # change directory to a window's location using its title | 57 # change directory to a window's location using its title |
| 61 DIR=$(xwininfo | dictify.py xwininfo | awk '{ print $NF }' | sed 's/"//g') | 58 DIR=$(xwininfo | dictify.py xwininfo | awk '{ print $NF }' | sed 's/"//g') |
| 62 DIR=${DIR/\~/$HOME} | 59 DIR=${DIR/\~/$HOME} |
| 63 cd $DIR | 60 cd $DIR |
| 64 } | |
| 65 | |
| 66 eend() { | |
| 67 # edit the end of a file with emacs | |
| 68 FILE=$1 | |
| 69 shift | |
| 70 emacs +`wc -l "$FILE"` $@ | |
| 71 } | |
| 72 | |
| 73 git-diff-master() { | |
| 74 git diff $(git merge-base HEAD master) | |
| 75 } | 61 } |
| 76 | 62 |
| 77 function colors() { | 63 function colors() { |
| 78 | 64 |
| 79 CLR_WHITE="\033[0;37m" | 65 CLR_WHITE="\033[0;37m" |
| 94 CLR_YELLOWBOLD="\033[1;33m" | 80 CLR_YELLOWBOLD="\033[1;33m" |
| 95 CLR_NOTHING="\033[0m" | 81 CLR_NOTHING="\033[0m" |
| 96 } | 82 } |
| 97 colors | 83 colors |
| 98 | 84 |
| 85 eend() { | |
| 86 # edit the end of a file with emacs | |
| 87 FILE=$1 | |
| 88 shift | |
| 89 emacs +`wc -l "$FILE"` $@ | |
| 90 } | |
| 91 | |
| 92 git-diff-master() { | |
| 93 # differences of a git repository with master | |
| 94 git diff $(git merge-base HEAD master) | |
| 95 } | |
| 96 | |
| 99 # nice fast find function | 97 # nice fast find function |
| 100 EXCLUDES="(\.svn)|(\.mo$)|(\.po$)|(\.pyc$)" | 98 EXCLUDES="(\.svn)|(\.mo$)|(\.po$)|(\.pyc$)" |
| 101 ff() { | 99 ff() { |
| 102 | 100 |
| 103 if (( $# < 2 )) | 101 if (( $# < 2 )) |
| 154 grep --color=auto -i -n -C 3 "$1" $i | 152 grep --color=auto -i -n -C 3 "$1" $i |
| 155 done | 153 done |
| 156 | 154 |
| 157 } | 155 } |
| 158 | 156 |
| 159 # make a temporary file | 157 # make a temporary file if `tempfile` not available |
| 160 tmpfile() { | 158 tmpfile() { |
| 161 | 159 |
| 162 if [ "$#" == "0" ] | 160 if [ "$#" == "0" ] |
| 163 then | 161 then |
| 164 args="tmp" | 162 args="tmp" |
| 165 else | 163 else |
| 166 args=$@ | 164 args=$@ |
| 167 fi | 165 fi |
| 168 | 166 |
| 169 for i in $args | 167 for i in $args |
| 170 do | 168 do |
| 171 NEWNAME=${i}.$RANDOM | 169 NEWNAME=${i}.$RANDOM |
| 172 | 170 |
| 173 while [ -e $NEWNAME ] | 171 while [ -e $NEWNAME ] |
| 174 do | 172 do |
| 175 NEWNAME=${NEWNAME}.tmp | 173 NEWNAME=${NEWNAME}.tmp |
| 176 done | 174 done |
| 177 echo "$NEWNAME" | 175 echo "$NEWNAME" |
| 178 done | 176 done |
| 179 } | 177 } |
| 180 | 178 |
| 181 edpe() { | 179 edpe() { |
| 182 # edit and pipe the buffer to stdout | 180 # edit and pipe the buffer to stdout |
| 183 FILE=`tmpfile` | 181 FILE=`tmpfile` |
| 184 $EDITOR $FILE | 182 $EDITOR $FILE |
| 185 cat $FILE | 183 cat $FILE |
| 186 rm $FILE | 184 rm $FILE |
| 185 } | |
| 186 | |
| 187 isrunning() { | |
| 188 # is a process running? (by name) | |
| 189 # see also: talos for a better version | |
| 190 for i in "$@" | |
| 191 do | |
| 192 ps axwww | grep "$i" | grep -v 'grep' | |
| 193 done | sort | uniq | |
| 194 | |
| 195 } | |
| 196 | |
| 197 killbyname() { | |
| 198 # kill a process by name | |
| 199 kill `isrunning "$@" | awk '{ print $1 }' | onelineit.py` | |
| 200 } | |
| 201 | |
| 202 fn() { | |
| 203 # full name | |
| 204 python -c "import os; print os.path.realpath('$*')" | |
| 205 } | |
| 206 | |
| 207 pyfile() { | |
| 208 # python file name | |
| 209 python -c "import $1; print $1.__file__" | |
| 187 } | 210 } |
| 188 | 211 |
| 189 swap() { | 212 swap() { |
| 190 # swap two files | 213 # swap two files |
| 191 if [ "$#" != "2" ] | 214 if [ "$#" != "2" ] |
| 192 then | 215 then |
| 193 echo "Usage: $FUNCNAME <first_arg> <second_arg>" | 216 echo "Usage: $FUNCNAME <file1> <file2>" |
| 194 return | 217 return |
| 195 fi | 218 fi |
| 196 for i in "$1" "$2" | 219 for i in "$1" "$2" |
| 197 do | 220 do |
| 198 if [ ! -w "$i" ] | 221 if [ ! -w "$i" ] |
| 201 return 1 | 224 return 1 |
| 202 fi | 225 fi |
| 203 done | 226 done |
| 204 | 227 |
| 205 NEWNAME=`basename $1`.$RANDOM | 228 NEWNAME=`basename $1`.$RANDOM |
| 206 | |
| 207 while [ -e $NEWNAME ] | 229 while [ -e $NEWNAME ] |
| 208 do | 230 do |
| 209 NEWNAME=${NEWNAME}.tmp | 231 NEWNAME=${NEWNAME}.tmp |
| 210 echo "$NEWNAME" | 232 echo "$NEWNAME" |
| 211 done | 233 done |
| 212 | 234 |
| 213 mv `basename $1` $NEWNAME | 235 mv "$1" "$NEWNAME" |
| 214 mv `basename $2` `basename $1` | 236 mv "$2" "$1" |
| 215 mv $NEWNAME `basename $2` | 237 mv "$NEWNAME" "$2" |
| 216 } | 238 } |
| 217 | 239 |
| 218 isrunning() { | 240 |
| 219 # is a process running? (by name) | |
| 220 # see also: talos for a better version | |
| 221 for i in "$@" | |
| 222 do | |
| 223 ps axwww | grep "$i" | grep -v 'grep' | |
| 224 done | sort | uniq | |
| 225 | |
| 226 } | |
| 227 | |
| 228 killbyname() { | |
| 229 # kill a process by name | |
| 230 # see also: talos for a better version | |
| 231 kill `isrunning "$@" | awk '{ print $1 }' | onelineit.py` | |
| 232 } | |
| 233 | |
| 234 # full name | |
| 235 fn() { | |
| 236 python -c "import os; print os.path.realpath('$*')" | |
| 237 } | |
| 238 | |
| 239 # which view | |
| 240 whview() { | 241 whview() { |
| 242 # which view | |
| 241 less `which $@` | 243 less `which $@` |
| 242 } | 244 } |
| 243 | 245 |
| 244 # which emacs | |
| 245 whemacs() { | 246 whemacs() { |
| 247 # which emacs | |
| 246 emacs -nw `which $@` | 248 emacs -nw `which $@` |
| 247 } | 249 } |
| 248 | 250 |
| 249 pyfile() { | 251 ### functions for python |
| 250 # python file name | 252 |
| 251 python -c "import $1; print $1.__file__" | 253 setup-all() { |
| 254 # setup all for development | |
| 255 # TODO: flowerbed? | |
| 256 for i in * | |
| 257 do | |
| 258 if [ -e "${i}/setup.py" ] | |
| 259 then | |
| 260 cd "${i}" | |
| 261 python setup.py develop | |
| 262 cd .. | |
| 263 fi | |
| 264 done | |
| 252 } | 265 } |
| 253 | 266 |
| 254 ### functions for version control systems | 267 ### functions for version control systems |
| 255 | 268 |
| 256 svndance(){ | 269 svndance(){ |
| 266 return 1 | 279 return 1 |
| 267 fi | 280 fi |
| 268 } | 281 } |
| 269 | 282 |
| 270 difffiles() { | 283 difffiles() { |
| 271 grep '^+++ ' $@ | sed 's/+++ b\///' | 284 grep '^+++ ' $@ | sed 's/+++ b\///' |
| 272 } | 285 } |
| 273 | 286 |
| 274 hg-update-all() { | 287 hg-update-all() { |
| 275 for i in *; | 288 # update all hg repositories in the current directory |
| 276 do | 289 for i in *; |
| 277 if [ -e $i/.hg ] | 290 do |
| 278 then | 291 if [ -e $i/.hg ] |
| 279 cd $i | 292 then |
| 280 hg pull | 293 cd $i |
| 281 hg update | 294 hg pull |
| 282 cd - | 295 hg update |
| 283 fi | 296 cd - |
| 284 done | 297 fi |
| 298 done | |
| 285 } | 299 } |
| 286 | 300 |
| 287 hg-qcommit() { | 301 hg-qcommit() { |
| 288 message=$1 | 302 message=$1 |
| 289 hg qrefresh | 303 hg qrefresh |
| 290 if [ -z "${message}" ] | 304 if [ -z "${message}" ] |
| 291 then | 305 then |
| 292 hg qcommit | 306 hg qcommit |
| 293 else | 307 else |
| 294 hg qcommit -m "${message}" | 308 hg qcommit -m "${message}" |
| 295 fi | 309 fi |
| 296 hgroot=$(hg root) | 310 hgroot=$(hg root) |
| 297 patches=${hgroot}/.hg/patches/ | 311 patches=${hgroot}/.hg/patches/ |
| 298 if [ -e ${patches}.hg ] | 312 if [ -e ${patches}.hg ] |
| 299 then | 313 then |
| 300 cd ${patches} | 314 cd ${patches} |
| 301 hg push | 315 hg push |
| 302 fi | 316 fi |
| 303 cd - | 317 cd - |
| 304 } | 318 } |
| 305 | 319 |
| 306 hgrc() { | 320 hgrc() { |
| 307 # write an hgrc file | 321 # write an hgrc file |
| 308 # TODO: in the case you're in an `hg root`...what then? | 322 # TODO: in the case you're in an `hg root`...what then? |
| 317 } | 331 } |
| 318 | 332 |
| 319 ### functions for web content | 333 ### functions for web content |
| 320 | 334 |
| 321 blog-file() { | 335 blog-file() { |
| 322 echo "$HOME/web/blog/k0s/entries/public/$1" | 336 echo "$HOME/web/blog/k0s/entries/public/$1" |
| 323 } | 337 } |
| 324 | 338 |
| 325 flatten() { | 339 flatten() { |
| 326 directory=$PWD | 340 directory=$PWD |
| 327 if [ "$#" == "1" ] | 341 if [ "$#" == "1" ] |
| 368 source ~/.bash_overrides | 382 source ~/.bash_overrides |
| 369 | 383 |
| 370 ### regenerate fluxbox menus here for convenience | 384 ### regenerate fluxbox menus here for convenience |
| 371 MENU=~/web/site/programs.html | 385 MENU=~/web/site/programs.html |
| 372 regeneratefluxmenu() { | 386 regeneratefluxmenu() { |
| 373 if [ -e $MENU ] | 387 if [ -e $MENU ] |
| 374 then | 388 then |
| 375 html2flux.py $MENU > ~/.fluxbox/applications | 389 # XXX could be safer |
| 376 fi | 390 html2flux.py $MENU > ~/.fluxbox/applications |
| 391 fi | |
| 377 } | 392 } |
| 378 regeneratefluxmenu | 393 regeneratefluxmenu |
