# The .cshrc file is started whenever you start a new csh/tcsh shell.
# This one does the following:
#
#    1) set the path variable so that commands can be found
#    2) sets other useful environment variables 
#    3) defines useful command aliases
#    4) makes adjustments for different flavours of Unix.
#
# Eric Myers <myers@vassar.edu>   Vassar College - Poughkeepsie, New York
# @(#) $Revision: 4.1 $ + $Date: 2003/09/09 17:46:22 $ + $Author: myers $
#######################################################################
## @(#) 1a) Path: try to cover all bases for a variety of machines

# General User:  if you are worried about security you may want to
# remove "." from the path, or put it last instead of first.


if ( "$HOME" != "/" && "$HOME" != "/root" ) then
  set path=( . ~/bin /usr/local/bin /usr/local/gnu/bin ) 
else
  set path=( /usr/local/bin /usr/local/gnu/bin ) 
endif


## University of Michigan ITD machine paths (if they exist):

if ( -d /usr/um/bin)   set path = ( $path  /usr/um/bin  /usr/um/gnu/bin )
if ( -d /usr/itd/bin)  set path = ( $path  /usr/itd/bin /usr/vice/bin ) 

## X-window system stuff

if ( -d /usr/local/X11 ) set path = ( $path  /usr/local/X11 )
if ( -d /usr/X11R6/bin ) set path = ( $path  /usr/X11R6/bin )
if ( -d /usr/X11R5 )     set path = ( $path  /usr/X11R5 )
if ( -d /usr/bin/X11 )   set path = ( $path  /usr/bin/X11 )

## BSD if it exists:

if ( -d /usr/ucb )	set path=( $path /usr/ucb ) 	# BSD
if ( -d /usr/bsd )	set path=( $path /usr/bsd ) 	# BSD support on SGI

set path=( $path /usr/bin /bin )	# standard stuff

# AFS

if ( -d /usr/vice/bin )    set path=( $path /usr/vice/bin )   #
if ( -d /usr/afsws/bin )    set path=( $path /usr/afsws/bin /usr/afsws/etc )

# Assorted specialized directories:

if ( -d /usr/lib/teTeX/bin ) set path=( $path /usr/lib/teTeX/bin ) # teTeX
if ( -d /opt/ansic/bin )    set path=( $path /opt/ansic/bin )    # HP ANSI C
if ( -d /opt/SUNWspro/bin ) set path=( $path /opt/SUNWspro/bin ) # Solaris 
if ( -d /usr/5bin )     set path=( $path /usr/5bin )    # SunOS SYSV support
if ( -d /usr/ccs/bin )  set path=( $path /usr/ccs/bin ) # Solaris/HP C compiler
if ( -d /usr/games )    set path=( $path /usr/games )   # BSD games

# BNL SGI uses these

if ( -d /PublicDomain/bin ) set path=( $path /PublicDomain/bin ) # BNL
if ( -d /PrivateDomain/bin ) set path=( $path /PrivateDomain/bin ) # BNL


###########################
## @(#) 1b) Man Path: places to look for man pages  (can omit share/man)
#           (this is a different method of constructing a path)

set MANLIST=( /usr/local/gnu/man /usr/local/man /usr/man /usr/share/man )
set MANLIST=( $MANLIST /usr/X11R6/man /usr/X11R6/LessTif/doc/man )
set MANLIST=( $MANLIST /opt/fortran /opt/ansic /opt/imake /opt/lrom )
set MANLIST=( $MANLIST /usr/lang/man /usr/openwin/man )

setenv MANPATH "$HOME/man"
foreach MANDIR ( $MANLIST )
  if ( "$MANDIR:t" != "man" ) then
    if ( -d $MANDIR/man ) then
      set MANDIR = "$MANDIR/man"
    else if ( -d $MANDIR/share/man ) then
      set MANDIR = "$MANDIR/share/man"
    endif
  endif
  if ( -d $MANDIR ) setenv MANPATH "${MANPATH}:${MANDIR}"
end
unset MANLIST MANDIR


#######################################################################
## @(#) 2) Environment:
##
## Make sure $user, $USER, and $mail are set, even on "dumb" systems.

if ( ! $?user ) set user=`/bin/whoami`

if ( ! $?USER ) then
  setenv USER=`/bin/whoami`
endif

## If this is an rsh shell we need a "dumb" terminal type:

if ($?TERM == 0)  setenv TERM dumb

## These are useful even for a noninteractive shell:

setenv TMPDIR	/tmp				# default temp space
if ( -d $HOME/tmp ) setenv TMPDIR $HOME/tmp	# personal temp space
if ( -d /usr0/tmp/$USER) setenv TMPDIR /usr0/tmp/$USER # large disk on dirac


setenv TAPE	/dev/rmt/0mnb			# default tape drive (HP)
if ( -r /dev/nrst0 )  setenv TAPE /dev/nrst0	# Sun/NeXT by default
if ( -r /dev/nst0 )  setenv TAPE /dev/nst0	# Linux SCSI tape drive


## If this is not an interactive shell then we are done.

if ($?prompt == 0) exit 0

## Set up Interactive Environment:

umask 022			# default is group/world read permission
set notify				# notify me of job changes
set ignoreeof				# prevent accidental ^D logout
set shell=/bin/csh			# csh for subshells even if using tcsh
set history=24 savehistory=30		# command history
if ( $?MAIL ) then
  set mail=$MAIL			# mail notification ON
endif
limit coredumpsize 0k			# no core dumps!

setenv EDITOR "emacs -nw"		# Don't start a window for emacs in X11

setenv SHELL /bin/csh			# for subshells (not tcsh!)
setenv PPR "enscript -p- -2rG -TUS -L66 "	# how to *print* 
setenv VDEVICE X11				# VOGL graphics device

# TeX setup:

setenv TEXEDIT   "\emacs -nw +%d %s"
if ( -d /usr/local/texmf ) then
  setenv TEXFORMATS ${TEXFORMATS}:/usr/local/texmf/ini//
  setenv TEXINPUTS  ${TEXINPUTS}:/usr/local/texmf/tex//
else if ( -d /usr/lib/teTeX ) then
  setenv TEXFORMATS ${TEXFORMATS}:/usr/lib/teTeX/texmf/web2c//
  setenv TEXINPUTS  ${TEXINPUTS}:/usr/lib/teTeX/texmf/tex//
endif


## Put current directory in csh prompt:

set prompt="% "
set X = `hostname | tr . ' ' ` ; set X = $X[1]
setenv HOST $X; unset X
alias setprompt 'set prompt="${HOST}:$cwd:t> "'
if ( `whoami` == "root") alias setprompt 'set prompt="${HOST}:$cwd:t# " '
if ( $TERM == "emacs" || $TERM == "unknown" || $TERM == "dumb" ) \
	    alias setprompt set prompt=\"% \"
alias cd  'cd \!* ; setprompt'
alias pd  'pushd \!* ; setprompt '
alias pop 'popd \!* ; setprompt'
setprompt

#######################################################################
## @(#) 3) Command Aliases: 

alias emacs emacs -nw			# No new windows for emacs
alias mroe more				# since it is easy to type this instead
alias msgs msgs -p			# msgs uses more to page
alias ls ls -F				# -F show executabls and links
alias dirf 'ls -tlFg \!* | more '       # full directory listing
alias rm rm -i				# some protection
alias mv mv -i				# some more protection
alias cp cp -i				# even more protection
alias cx chmod +x			# to make a file executable
alias cw chmod +w			# to make a file writeable
alias hide chmod go-rwx			# to hide files
alias unhide chmod go+r			# to make files public
alias lo logout
alias h history
alias c clear
alias gs gs -q			# ghostscript should be seen, not heard
alias gv ghostview
alias screen 'screen -fn -R'

alias psgrep   'ps -acuxg | grep \!* | grep -v grep'
alias ffind 'find . -name "*\!{^}*" \!:2*  -print '  # find a file
alias du-s du -s \* \| sort -n		

## Alias these commands only if real ones are/aren't there

if ( -x /usr/local/bin/mush ) then
  alias mail mush	
endif
if ( ! -x /usr/local/bin/info) then
  alias info emacs -f -info
endif
if ( -x /usr/local/bin/less ) alias more less -EX

alias learn-emacs emacs -f help-with-tutorial


## VMS command synonyms (can't hurt, might help):

alias dir ls
alias copy cp -i
alias delete rm -i 
alias type cat
alias rename mv -i
alias fort f77

#######################################################################
## @(#) 4) Different Flavours of Unix:

set UNAME = "unknown"
if ( -x /usr/bin/uname )       set UNAME = `/usr/bin/uname` 
if ( -x /usr/local/bin/uname ) set UNAME = `/usr/local/bin/uname` 

#############
## Linux

if ( "$UNAME" ==  "Linux" ) then
  setenv TAPE /dev/fd0

  alias dirf 'ls -ltFg $LS_OPTIONS  --color=always \!* | more '       
  alias psgrep   'ps aux | grep \!* | grep -v grep'
  if ( -x /usr/info) unalias info

  if ( "`groups | grep adm `" != "" || `whoami` == "root") then
    set path=( $path /usr/local/adm /sbin /usr/sbin )
  endif

  # This is at the end because it may fail 
  unsetenv LS_COLORS
  eval `dircolors -c`

endif



#############
## Darwin (Mac OS X)

if ( "$UNAME" ==  "Darwin" ) then

  alias psgrep   'ps -auxww | grep \!* | grep -v grep'

  if ( "`groups | grep adm `" != "" || `whoami` == "root") then
    set path=( /usr/local/adm /usr/local/sbin  $path  /sbin /usr/sbin  )
  endif

  # Fink initialization:

  if ( -f /sw/bin/init.csh ) then 
    source /sw/bin/init.csh
    set path=( $path /sw/bin )
  endif

endif



#############
## Solaris:

if ( -f /kernel/genunix && "$UNAME" ==  "SunOS" ) then
  set path=( $path /usr/openwin/bin/ )
  alias ps5	'ps -el | sort -snr +6 |  head -6 '
  alias psgrep 	'ps -ef | grep \!* | grep -v grep'
  alias dirf 'ls -tlF \!* | more '	# full directory listing
  setenv TAPE /dev/rmt/0mnb
endif


#############
## SGI/IRIX

if ( "$UNAME" ==  "IRIX64" ) then
  alias psgrep  'ps -Af | grep \!* | grep -v grep'
    set path=( $path /usr/bsd )
endif

if ( "$UNAME" ==  "IRIX" ) then
    set path=( $path /usr/bsd )
endif


#############
## NeXTSTep/mach:

if ( -f /sdmach ) then 
  set path=( $path ~/Apps /LocalApps /NextApps /NextDeveloper/Demos ) 
  alias lpq lpq -P\$PRINTER		# dumb NeXT!
  alias lpr lpr -P\$PRINTER		# dumb NeXT!
  if ( "$UNAME" == "unknown" ) alias uname echo NEXTSTEP
  set UNAME = NEXTSTEP
  alias rlast 'rsh \!^ -n last  \!:2* | more'
  setenv TAPE /dev/nrst0

  if ( "$user" == "root") then
    set path= ( /NextAdmin /usr/etc /etc $path ) # dot not first!
    unset ignoreeof	
  endif
endif


#############
## HP-UX 9.x or 10.X

if ( -f /hp-ux || -f /stand/vmunix && "$UNAME" == "HP-UX" ) then
  set path=( $path /usr/contrib/bin /usr/contrib/bin/X11 )
  if ( -d /opt/ansic/bin ) set path=( $path /opt/ansic/bin ) # HP ANSI C
  alias ps5	'top -d1 -n5'
  alias psgrep 	'ps -ef | grep \!* | grep -v grep'
  alias dirf 'ls -tlF \!* | more '	# full directory listing
  if ( ! -x /usr/bin/lpr ) alias lpr lp -d\${LPDEST}
  alias lpq lpstat \${LPDEST}
  alias atq at -l
  alias atrm at -r 
  alias rsh remsh
  alias last last -R
  alias who  who  -R
  alias rlast 'remsh \!^ -n last -R \!:2* | more'

  if ( -d /opt/lrom ) then  ## HP LaserROM on-line manuals
    set path=( $path /opt/lrom/bin )
    setenv MANPATH ${MANPATH}:/opt/lrom/share/man
  endif

  if ( `whoami` == "root") then
    set path=`echo $path | sed -e "s/\. //"`  # Remove 'dot' from path
    set path= ( /sbin /usr/etc /etc $path ) 
    unset ignoreeof	
  endif
endif


#############
## SunOS 4.x

if ( -f /vmunix && "$UNAME" ==  "SunOS" ) then
  alias ps5       'ps -auxg | head -6 '
  setenv TAPE /dev/nrst0
endif







##################################################
# No dot in root's path!!!

if ( `whoami` == "root") then
  set path=`echo $path | sed -e "s/\. / /"`  # Remove 'dot' from path
  unset ignoreeof     
endif


#######################################################################
## @(#) 6) Custom host configuration

if ( -x $HOME/.cshrc.`hostname` ) then
  source $HOME/.cshrc.`hostname`
endif

exit 0
