## Id: .bashrc,v 1.72 1998/10/26 13:36:00 reece Exp ## LICENSE ## This source code is hereby released to the public domain and is unsupported. ## You are encouraged to copy and modify this file. Please clearly document ## modifications with authorship and motivation. Bug reports, code ## contributions, and suggestions are appreciated. ## ## SOURCE ## New versions of this file may be obtained from (as of 1999/01/29) ## http://www.in-machina.com/~reece/setup/bashrc ## ftp://in-machina.com/pub/reece/setup/bashrc ## ## AUTHOR ## Reece Hart, http://www.in-machina.com/~reece/, PGP:0xD178AAF9 ## Do not send unsolicited bulk email. Boycott companies which do so. [ -t 0 ] && echo 'Id: .bashrc,v 1.72 1998/10/26 13:36:00 reece Exp' umask 022 # 644 (rw-r--r--) default ulimit -c 0 ulimit -d unlimited set -C # don't clobber files with > redirection (>| overrides) # This is my attempt to create order from chaos in platform naming # All info is derived from uname and lowercased. OS patchlevel is truncated. export OS=`uname -s | sed -e 's/ */-/g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` export OSVERSION=`uname -r`; OSVERSION=`expr "$OSVERSION" : '[^0-9]*\([0-9]*\.[0-9]*\)'` export MACHINE=`uname -m | sed -e 's/ */-/g;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` export PLATFORM="$MACHINE-$OS-$OSVERSION" # ENVIRONMENT VARIABLES # PATH convention is: # {,$HOME}/opt{,/arch1,/arch2}/{bin,src,man,info,etc,lib} # {bin } e.g., /opt/bin for arch-indep scripts # { / } { . } {src } /user/reece/opt/i686-linux-2.0/bin for linux binaries # {$HOME/} opt/ {arch1} / {man } # {arch2} {info} # {etc } # {lib } # with /opt/archx mounted over /usr/local if [ "$UID" = 0 ]; then RHOME=/user/reece export prefix=$RHOME/opt export exec_prefix=$RHOME/opt/$PLATFORM else export prefix=$HOME/opt export exec_prefix=$HOME/opt/$PLATFORM fi export ARCHIE="-u -h -H20" export ARCHIE_HOST=archie.rutgers.edu export AXHOME=$prefix/axhome export BGDIR=$prefix/backgrounds export BIBINPUTS=$HOME/pubs/bib/: export CLASSPATH=.:/usr/local/share/kaffe/classes.zip:/usr/local/share/kaffe/biss.zip export C_INCLUDE_PATH=$prefix/include export CVSROOT=$HOME/opt/cvs export DATEFMT="%Y/%m/%d" export DECFORT_FPP=/usr/local/bin/cpp export DOMAINNAME=wustl.edu export EMAIL_ADDRESS=reece@in-machina.com export FULLNAME="Reece Kimball Hart" export GZIP="-9v" [ -z "$HOSTNAME" ] && export HOSTNAME=`uname -n` export INFOPATH=$prefix/info:/usr/local/info:/usr/share/info:/usr/info export KAFFEHOME=/usr/local/share/kaffe export KDEDIR=/opt/kde export LATITUDE=38.6 export LC_TYPE=iso_8859_1 export LD_LIBRARY_PATH="$exec_prefix/lib:/usr/local/lib:$LD_LIBRARY_PATH:DEFAULT" export LESS='-M -i -x4' export LESSCHARSET=latin1 export LIBRARY_PATH=$LD_LIBRARY_PATH export LOGNAME=$USER export LONGITUDE=-90.3 if [ "$OS" != "linux" ]; then export MANPATH=$prefix/man:$exec_prefix/man:/usr/local/man:/usr/share/catman:/usr/share/man:/usr/catman:/usr/man fi export MOZILLA_HOME=/usr/local/netscape export NAME="$FULLNAME" export NAV_PRIVATE=$prefix/fplan export ORGANIZATION="Biophysics & Biochemistry, Washington University, St. Louis, USA" export PAGER=less export PATH=$prefix/bin:$exec_prefix/bin:$KDEDIR/bin:/usr/local/bin:/usr/bin/X11:$PATH:/usr/ucb export PERL5LIB=$prefix/lib/perl5/site_perl:$prefix/lib/perl5 export PGPPATH=$prefix/lib/pgp export PILOTRATE=57600 export RXVTPATH=$HOME/opt/patterns export TEXINPUTS=$prefix/lib/tex/:$prefix/lib/tex//: export TINKERLIB=$HOME/tinker export TMPDIR=$HOME/tmp [ -z "$USER" ] && export USER=`whoami` export VERSION_CONTROL=simple if [ -z "$PS1" ]; then # non-interactive shells (only) : else # interactive shells (only) # ensure these terminal settings or I go crazy stty intr ^C susp ^Z erase ^? kill ^U eof ^D start ^Q stop ^S lnext ^V # terminal type RXVT=0 if [ "${COLORTERM%%-*}" = "rxvt" ]; then RXVT=1 else case "${REMOTEHOST%%.wustl.edu}" in blitzen|comet|cupid|frosty|dasher|donner|prancer|vixen|whoville) RXVT=1;; *) if [ "$TERM" = "xterm" ]; then # Check for RXVT using xterm control sequence #ESC [ Ps c # Send Device Attributes (DA) # Ps = 0 (or omitted) : request attributes from terminal # returns: ESC[?1;2c (``I am a VT100 with Advanced Video Option'') stty -icanon -echo min 0 time 15 echo -n '' read term_id stty icanon echo if [ "${term_id}" = '[?1;2c' ]; then RXVT=1 fi fi;; esac fi # colorize rxvt, color-xterm, and linux terminals COLORIZE=0 if [ "$RXVT" = 1 -o "$TERM" = color-xterm -o "$TERM" = linux ]; then COLORIZE=1; fi # set prompt if [ "$UID" = 0 ]; then p='\u@\h\$'; else p='\h\$'; fi case "$TERM" in xterm*|linux) if [ "$COLORIZE" = 1 ]; then if [ "$UID" = 0 ]; then fi='\033[1;33;41m'; ff='\033[0;37m'; else fi='\033[1;31;43m'; ff='\033[0;37m'; fi else if [ "$UID" = 0 ]; then fi=`tput smso`; ff=`tput rmso`; else fi=`tput smso`; ff=`tput rmso`; fi fi PS1="\\[$fi\\]$p\\[$ff\\] " ;; emacs|dumb) PS1="$ ";; *) PS1="$p "; esac # ALIASES # 'cmd $var' NOT "cmd $var" => variables instantiated on the fly alias ..='cd ..; awd' alias .=awd alias cp='cp -bi' alias gv='ghostview -color -geometry -0-0' alias h=head alias j='jobs -l' alias ll='ls $LSFLAGS -lF' alias lla='ls $LSFLAGS -AlF' alias lld='ls $LSFLAGS -dlF' alias ls='ls $LSFLAGS -CF' alias lsa='ls $LSFLAGS -ACF' alias lo=exit alias p='$PAGER' alias mail='pine -z -i' alias mv='mv -bi' alias pcd='pushd' alias pd='popd' alias pa=pilot-addresses alias px=pilot-xfer alias rm='rm -i' alias rm~='rm -f *~ .*~ *.bak .*.bak' alias t=tail # InsightII molecular modelling software alias insightII="cd opt/lib/insightII; csh -c 'source /local/biosym/cshrc; /usr/local/bin/insight'" # Sybyl molecular modelling software export TA_ROOT=/local/sybyl alias sybyl="csh -c 'source $TA_ROOT/lib/.login; /local/sybyl/bin/sybyl'" # FUNCTIONS # verbose execution ve () { echo "${VEPFX:=+}$@" 1>&2; eval "$@"; } vet () { echo "${VEPFX:=+}$@" 1>&2; eval "uname -a; uptime; time $@"; } VEPFX='#* ' # revert files with .bak suffix revert () { for f in "$@"; do mv $f ${f%.bak}; done; } # common files in directories; e.g., commd d1 d2 -12 commd () { comm $3 <(builtin cd $1; find .|sort) <(builtin cd $2; find .|sort); } # diff files common to two directories given as args diffd () { commd $1 $2 -12 | tail +2 | while read fn; do cmd="diff -c $1/$fn $2/$fn"; echo "# $cmd"; $cmd; done; } # dasher get and put dg () { echo getting:; echo "$@"; rsh -n dasher unset GZIP\; tar czf - "$@" | tar xUvzf -; } dp () { echo puting:; echo "$@"; tar czf - "$@" | rsh dasher unset GZIP\; tar xUvzf -; } dc () { echo comparing:; echo "$@"; md5sum $@ | rsh dasher md5sum -c; } dd () { for f in "$@"; do echo + $f; diff $f mnt/dasher/$f; done; } # wait for file to (not) exist wfe () { while [ \! -e "$1" ]; do sleep ${2:-60}; done; } wfne () { while [ -e "$1" ]; do sleep ${2:-60}; done; } # abbreviated and relative working directory awd () { case $PWD in $HOME|$HOME/*) echo '~'${PWD#$HOME};; *) echo $PWD;; esac; } rwd () { case $PWD in $HOME) echo;; $HOME/*) echo ${PWD#$HOME/};; *) echo $PWD;; esac; } # unzip files into a directory with the same root name as the file uz () { unzip -d ${1%.zip} $1; } # convert pdf to postscript pdf2ps () { (set -x; for f in "$@"; do acrobat -toPostScript -level2 -pairs "$f" "${f%pdf}ps"; done); } if [ "$TERM" = "xterm" ]; then # set title of xterm xtitle() { echo -n "]1;$1]2;$1"; } # that's ESC ] 2 ; title C-g xtitle "$USER@${HOSTNAME%%.*}:`awd`"; # set initial title # cd & change xterm title cd () { builtin cd $1; xtitle "$USER@${HOSTNAME%%.*}:`awd`"; }; unalias pcd pd pcd () { builtin pushd $1; xtitle "$USER@${HOSTNAME%%.*}:`awd`"; }; pd () { builtin popd; xtitle "$USER@${HOSTNAME%%.*}:`awd`"; }; # display a pixmap in an rxvt window rxvtpm() { echo -n "]20;$1"; } fi # page executable (a script, we hope) pe () { $PAGER `type -p "$@"`; } # colorized ls LSFLAGS= if [ "$COLORIZE" = 1 ]; then if [ -f $HOME/.dir_colors ]; then eval `dircolors $HOME/.dir_colors`; fi if [ -n "$LS_COLORS" ]; then LSFLAGS=--color fi fi # totalview and applix both use LM_LICENSE_FILE, therefore it can't # be broadly exported. Sigh. tv () { export LM_LICENSE_FILE="/local/totalview.3.4.2-4/totalview/flexlm/license.dat"; totalview "$@"; } fi