# $Id: .bashrc,v 1.25 2008/03/23 00:27:25 grog Exp $ bind 'set convert-meta on' case `uname` in Linux) PATH=.:~:/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bitkeeper export SHELL=/bin/bash ;; NetBSD) PATH=.:~:/usr/pkg/bin::/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bitkeeper:/usr/local/gnu-autotools/bin:~ export SHELL=/usr/pkg/bin/bash ;; FreeBSD) PATH=.:~:/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bitkeeper:/usr/local/gnu-autotools/bin:~ export SHELL=/usr/local/bin/bash ;; Darwin) PATH=.:~:/sw/bin:/sw/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bitkeeper export SHELL=/bin/bash ;; # Collected cruft of the centuries *) PATH=/usr/pkg/bin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bitkeeper:/usr/local/gnu-autotools/bin:~ export SHELL=/usr/local/bin/bash esac umask 022 if [ -e /usr/local/share/abbreviations ]; then source /usr/local/share/abbreviations else source ~/abbreviations fi if tty > /dev/null then stty erase ^h quit '^|' eof ^d echoe kill ^u intr ^c -istrip cs8 ssh-add -l > /dev/null if [ $? -ne 0 ]; then eval `ssh-agent` >/dev/null ssh-add fi fi # find a function in /usr/lib/lib* findfunc () { nm /usr/lib/lib*.a |egrep '^$1[ ]|Symbols from'|more } # grep recursively through all files in current directory and subdirectories grep4 () { find . -mount -type f -print | xargs -n10 grep -sn $1 | tee /tmp/$LOGNAME.greplist | more } # find a function in a list of object files or libraries # files default to /usr/lib/*.a ff () { if [ $# -lt 2 ] # no directory specified then FILES="*.o *.a" else FILES=$2 fi if [ $# -lt 1 ] #nothing specified then echo $0 Need at least function parameter else FUNCTION=$1 echo Searching for regexp $FUNCTION in $FILES sed "s:files:$FILES:;s:function:$FUNCTION:" ~/findf|sh|more fi } if [ -d /echunga/usr/local/www/data ]; then W=/echunga/usr/local/www/data fi if [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" ] ; then /usr/games/fortune -o PS1="\[\]=== \u@\h (`tty`) \[\]\w\[\] \# ->\[\]\[\] " else PS1="=== \u@\h (`tty`) \w \# -> " fi # find a file in list of backups bfind () { cd ~/backup (for i in `ls -t *.gz`; do tapename=`basename $i .gz` echo $i `grep "^$tapename[^0-9][X* ]" ~/backup` zcat $i | grep $1 done ) |less } cdfind () { cd ~/cdrom (for i in *.gz; do echo ----------------------------------------------- echo $i zcat $i | grep $1 done ) |less } showdiff () { case $1 in -*) shift; flags=$1; shift;; esac $* >/tmp/$1.t0 if [ "$flags" != "" ]; then sleep $flags else sleep 5 fi $* >/tmp/$1.t1 diff /tmp/$1.t[01] } rlogin () { xtset "rlogin $* (%T)" command rlogin $* cd . } readflop () { while [ -f /bsd ]; do echo -n "Enter file name: " read name dd if=/dev/rfd0 of=$name bs=36b done } readflopgz () { while [ -f /bsd ]; do echo -n "Enter file name: " read name dd if=/dev/rfd0 bs=36b | gzip >$name.gz done } writeflop () { while [ -f /bsd ]; do echo -n "Enter file name: " read name dd of=/dev/rfd0 if=$name bs=36b done } writeflopgz () { while [ -f /bsd ]; do echo -n "Enter file name: " read name zcat $name | dd of=/dev/rfd0 obs=36b done } bind 'set convert-meta on' function setenv { _SYM=$1; shift; export $_SYM="$*" } # CVS related functions. function CVS { REPO=grog@ncvs.freebsd.org:/home/ncvs if [ "$1" = "-c" ]; then REPO=grog@freefall.freebsd.org:/home/core/private/cvs shift; fi if [ "$1" = "-p" ]; then REPO=grog@ncvs.freebsd.org:/home/pcvs shift; fi if [ "$1" = "-n" ]; then REPO=grog@cvs.netbsd.org:/cvsroot shift; fi cvs -d $REPO $* } # function Cvs { # cvs -d grog@ncvs.freebsd.org:/home/ncvs $* # } # function Pcvs { # cvs -d grog@ncvs.freebsd.org:/home/pcvs $* # } # # function CoreCVS { # setenv CVSROOT freefall.freebsd.org:/home/core/private/cvs # setenv CVS_IGNORE_REMOTE_ROOT yes # [ -f CVS/Root ] && echo ${CVSROOT} > CVS/Root # cvs $* # setenv CVSROOT ${_LOCAL_CVS} # [ -f CVS/Root ] && echo ${CVSROOT} > CVS/Root # } # endname foo foobar strips the foo at the beginning of foobar and returns bar. endname () { echo $2 | sed "s:^$1::" } export HTML_TIDY=/home/grog/public_html/.tidyconfig # Temporary things export LJ=/src/Linux/ia32/2.4.18-kgdb-jfs1 export LJJ=/src/Linux/ia32/2.4.18-kgdb-jfs1/fs/jfs1 spr () { ORGANIZATION="LEMIS (SA) Pty Ltd" send-pr } mkimage() { DIR=/echunga/home/grog/public_html/Photos/`date '+%Y%m%d'` mkdir -p $DIR cd $DIR ln -s /echunga/home/grog/Photos/`date '+%Y%m%d'`/*.jpeg . make -f /echunga/home/grog/Photos/Makefile } export BLOCKPOOL=/var/tmp/blockpool/ order () { for i in $*; do echo $i touch $i sleep 1 done } ssh () { xtset -t $* xtset -i "%u@%h:%D" command ssh -A -X $* xtset -t "%u (%T) %h:%D" xtset -i "%u@%h:%D" logger ssh $* terminated echo Disconnected at `date` } sssh () { while :; do ssh $*; logger ssh $* terminated done } # Bitkeeper stuff. This includes license stuff, so put it in a # separate file that doesn't end up on the web site. if [ -f ~/.bitkeeper ]; then source ~/.bitkeeper fi # MySQL specific commands? if [ -f ~/.mysqlrc ]; then source ~/.mysqlrc fi Mutt () { DISPLAY=:0 cd ~/FreeBSD xtset Mail mutt } # Wild card rename. $1 is a globbing pattern for the file names to be # renamed, and $2 is a sed rule to explain how to change them. # # Despite the name, this function does not rename anything; it just # outputs commands to be put through a shell. MV () { for i in $1; do echo mv $i `echo $i | sed $2`; done } # Touch the files in the parameters in order, waiting a second in # between. This means that an ls -rt will then show them in that # order. timeorder () { for i in $*; do touch $i sleep 1 done } mailtunnel () { while :; do logger Restarting SMTP tunnel logger `ssh -n -N -L 2026:ozlabs.org:25 ozlabs.org` done } yt () { cd ~/youtube youtube-dl "$1" mplayer -display :0 `basename $1` } mpl () { if [ -f $1.cutlist ]; then mplayer -edl $1.cutlist -framedrop $1 else mplayer -framedrop $1 fi } # Replace spaces in names with -. # Supplied by Peter Jeremy. spaceout () { for i in "$@"; do mv "$i" $(echo "$i" | tr ' ' '-') done }