# $Id: abbreviations,v 1.28 2007/01/04 03:13:04 grog Exp $ # Default definitions sucked in by all bashes. # # This is the cruft of ages, originally started as a .bashrc on # Inactive System V/386 in about May 1990. # # Stuff that differs between OSs. # uname implementations differ in the way that they report the OS. # FreeBSD uses time(1) -s, Linux uses -o if [ `uname` = "Linux" ]; then # For Linux with these *horrible* colour ls functions unset COLORS LS_COLORS # And get man pages in correct width. export MANWIDTH=80 TIMECMD='/usr/bin/time -v' LESSCMD='less -X' # Get rid of these horrible Linux aliases. unalias -a # For some reason, I have lots of trouble with this macro under Linux. mailme () { cmd=$1 shift xtset mailme $cmd me=`who am i|awk '{print $1}'` # Why can't we deliver mail locally? echo $cmd $*' 2>&1 | tee /dev/tty | mail -s "mailme: $cmd $*" grog@lemis.com' $cmd $* 2>&1 | tee /dev/tty | mail -s "mailme: $cmd $*" grog@lemis.com cd . } else # Some BSD TIMECMD='/usr/bin/time -l' LESSCMD=less mailme() { cmd=$1 shift xtset mailme $cmd $cmd $* 2>&1 | tee /dev/tty | mail -s "mailme: $cmd $*" `who am i|awk '{print $1}'` cd . } fi # Environment variables export B=/home/Book export BLOCKSIZE=1048576 # for df # export CC=distcc # export DISTCC_HOSTS="wantadilla echunga zaphod adelaide sydney monorchid beeble" export CVSROOT=/home/ncvs export DIFFS=-c export EDITOR=emacsclient export F=/home/Book/FreeBSD-4 export FORCE_PKG_REGISTER="do it already" export L=/home/lemis export LESS='-a -F -i -j5 -M -X' export LESSCHARSET=latin1 export MANPATH=/usr/local/man:/usr/share/man:/usr/X11R6/man:/usr/local/bitkeeper/man:/usr/libexec/bitkeeper/man export MONKEY_CACHE="50 50 50 50 50" export MONKEY_LANGUAGE=German export PAGER=$LESSCMD export RSYNC_RSH=ssh export SHELL=/usr/local/bin/bash export TAPE=/dev/nsa0 export USA_RESIDENT=NO export V=/src/vinum export W=/usr/local/www/data export _CVS_REMOTE_HOST=freefall.freebsd.org export _LOCAL_CVS=/home/ncvs export _REMOTE_CVS=${_CVS_REMOTE_HOST}:/home/ncvs # Initialization case `tty` in /dev/ttyp*) TERM=xterm-color ;; /dev/pts/*) TERM=xterm-color ;; /dev/ttyq*) TERM=xterm-color ;; /dev/ttyv*) TERM=cons25 ;; *) TERM="" ;; esac export TERM # Functions alias l="ls -lL" alias lc="ls -CF" # Remove a target file, then make it. remake () { rm $1 make $* } # Run 'make' and log the results to the file ./Make.log. Make() { xtset `uname -n|sed 's:\..*$::'`:`pwd`: Make "$* "`date` (echo '=====' `date` on `hostname`: Make $*; $TIMECMD make 2>&1 $*) | tee -a Make.log pwd=`pwd` if [ `echo $pwd | grep /ports/` ]; then mkdir -p /home/Sysconfig/Makelogs echo `date` `pwd` make $* >> /home/Sysconfig/installed-ports cat Make.log >> /home/Sysconfig/Makelogs/`basename $pwd` fi cd . } # Run 'gmake' and log the results to the file ./Make.log. Gmake () { xtset `uname -n | sed 's:\..*$::'`:`pwd`: Gmake "$* "`date` (echo '=====' `date` on `hostname`: Gmake $*; $TIMECMD gmake 2>&1 $*) | tee -a Make.log cd . } # Run a command and log it to a file Log.log. Log () { xtset `uname -n | sed 's:\..*$::'`:`pwd`: $* `date` (echo '=====' `date` on `hostname`: $*; $TIMECMD 2>&1 $*; echo $1 finished at `date`) | tee -a Log.log cd . } # Change directory and set the xterm heading to match. This breaks # badly with brain-dead directories containing spaces. Use 'command # cd' to bypass it in this case. cd () { command cd $* if [ $? = 0 ]; then xtset -t "%u (%T) %h:%D" xtset -i "%u@%h:%D" true else false fi } # Push directory (shell 'pushd' builtin) and set the xterm heading to # match. This breaks badly with brain-dead directories containing # spaces. Use pushd to bypass it in this case. pd () { builtin pushd $* xtset -t "%u (%T) %h:%D" xtset -i "%u@%h:%D" } # Pop directory (shell 'popd' builtin) and set the xterm heading to # match. This breaks badly with brain-dead directories containing # spaces. Use 'command popd' to bypass it in this case. popd () { builtin popd $* xtset -t "%u (%T) %h:%D" xtset -i "%u@%h:%D" } # rlogin and set the xterm heading to match. rlogin () { xtset -t $* xtset -i "%u@%h:%D" command rlogin $* xtset -t "%u (%T) %h:%D" xtset -i "%u@%h:%D" } neti () { if [ "$1" = "" ]; then delay=5 else delay=$1 fi netstat -s >/tmp/netstat1 sleep $delay netstat -s >/tmp/netstat2 diff /tmp/netstat1 /tmp/netstat2 } nfss () { if [ "$1" = "" ]; then delay=5 else delay=$1 fi nfsstat >/tmp/netstat1 sleep $delay nfsstat >/tmp/netstat2 diff /tmp/netstat1 /tmp/netstat2 } cpqic () { (while [ -d / ]; do dd if=/dev/rst0 obs=20b echo -n >/dev/tty Next tape: read reply if [ "$reply" = 'q' ]; then exit fi done) | rsh allegro dd ibs=20b obs=128b of=/dev/nrst0 } # search for a string in all man pages. Unformatted man pages stay unformatted. findman () { (for i in `echo $MANPATH|sed 's*:* *g'`; do find $i -type f -name "*.gz" -or -name "*.Z" -print|xargs zcatgrep $1 2>/dev/null find $i -type f ! \( -name "*.gz" -or -name "*.Z" \) -print|xargs grep $1 done) | $LESSCMD } function setenv { _SYM=$1; shift; export $_SYM="$*" } # CVS related functions. function do-local-cvs { setenv CVSROOT ${_LOCAL_CVS} setenv CVS_IGNORE_REMOTE_ROOT yes [ -f CVS/Root ] && echo ${CVSROOT} > CVS/Root } function do-remote-cvs { setenv CVSROOT ${_REMOTE_CVS} setenv CVS_IGNORE_REMOTE_ROOT yes [ -f CVS/Root ] && echo ${CVSROOT} > CVS/Root } function cvscommit { do-remote-cvs cvs commit $* do-local-cvs } remake () { rm $1 make $* } burn() { # defaults for my setup SPEED=16 DEV=1,0,0 DUMMY= if [ "$1" = "" ]; then echo Usage: burncd filename [dummy flag] else if [ "$2" != "" ]; then # dummy burn DUMMY=-dummy fi cdrecord $DUMMY -v dev=$DEV -speed=$SPEED $1 fi } # Variant of which(1) that shows all potential commands in the order # found in PATH. Shows an ls -l listing for each of them. wh () { tmpfile=/tmp/`basename $0`.$$ (for j in $*; do for i in `echo $PATH|sed 's/:/ /g'`; do if [ -f $i/$j ]; then echo $i/$j fi done done) >$tmpfile if [ -s $tmpfile ]; then # GNU ls treats -lf and -fl differently xargs <$tmpfile ls -fl else echo No files found fi rm $tmpfile } # Make a corresponding RCS directory in /home/Sysconfig/MasterRCS and # symlink to it. mkRCS () { sysconfig=/home/Sysconfig/MasterRCS cwd=`pwd` if [ -d RCS ]; then if [ -e RCS.old ]; then echo RCS.old already exists. Please check and repeat if necessary. ls -lL RCS RCS.old return fi mkdir -p $sysconfig$cwd echo Copying control files: tar cf - RCS| (cd $sysconfig$cwd; tar xvf - ) mv RCS RCS.old ln -s $sysconfig$cwd/RCS RCS echo '*** Check' $cwd/RCS.old and remove when OK '***' ls -lL RCS RCS.old elif [ -e RCS ]; then echo $cwd/RCS exists and is not a directory. Please check return else mkdir -p $sysconfig$cwd/RCS ln -s $sysconfig$cwd/RCS RCS fi } installport () { cwd=`pwd` cd $1 if [ $? -ne 0 ]; then return 1 fi export BATCH=dammit A4=yes make clean; Make install (echo '=====' `date` on `hostname`: Make install; $TIMECMD make 2>&1 install if [ $? -eq 0 ]; then pwd >> /home/Sysconfig/installed-ports fi) | tee -a Make.log cd $cwd } # Set the xterm headers xtset -t "%u (%T) %h:%D" xtset -i "%u@%h:%D"