# Global cshrc file
#
# $Id: cshrc,v 1.8 96/01/28 15:37:03 svalente Exp Locker: svalente $

# This file is sourced by default user file ~/.cshrc

set initdir=/usr/athena/lib/init

# *******************   ENVIRONMENT SETUP   *******************

# Set standard path variables, for reference (actual paths set later in file).

# Set standard Athena path variable (generic path for all users):
set athena_path=( /srvd/patch /usr/local/sbin /usr/local/bin /usr/athena/bin \
		/bin/athena /usr/X11/bin /usr/bin/X11 /sbin /usr/sbin \
		/bin /usr/bin /usr/andrew/bin /usr/games )

# Set appropriate bin directory variable for this platform
# (e.g., vaxbin for VAXstations, decmipsbin for pMAXen, etc.;  this will
# be included in actual searchpath as ~/$bindir -- e.g., ~/vaxbin):
if (! $?hosttype ) set hosttype=`/bin/athena/machtype`
set bindir=${hosttype}bin

# Set standard path of directories for man command to search:
#
# /usr/man/preformat is used by slackware linux
# /usr/share/man is used by netbsd
#
set athena_manpath=/usr/athena/man:/usr/X11/man:/usr/man:/usr/man/preformat:/usr/share/man

# Set up standard system/user environment configuration (including setup of
# environment variables, attachment of lockers, and setting of search path)

if (! $?ENV_SET) then

	setenv ENV_SET				# Avoid unnecessary repeat

	umask 077				# Strictly protect files
						#  (does not apply in AFS)
	limit coredumpsize 0			# Don't allow coredumps
	if ( "$hosttype" == "inbsd" ) then
		setenv MORE -cs			# -d only recently supported
	else
		setenv MORE -csd		# Default "more" behavior
	endif
	setenv EDITOR emacs			# Set default editor
	setenv VISUAL emacs			# Set default screen editor
	setenv RSUSERHOME ~/rsuserhome		# Default RS/1 directory for R3

	setenv MANPATH $athena_manpath

	setenv ATHENA_SYS `/bin/athena/machtype -S`
	if ( $ATHENA_SYS == "" ) then
		unsetenv ATHENA_SYS
	endif

	if ( ! $?PRINTER && -e /etc/athena/clusterinfo ) then
	  setenv PRINTER `awk '/LPR/ { print $3 }' /etc/athena/clusterinfo`
	  if ( $PRINTER == "" ) unsetenv PRINTER
	endif

	# Reset the "home" and HOME variables to correspond to the
	# actual location of the user's home directory.  This will
	# avoid having long pathnames being printed when /mit/<user>
	# is a symlink to a path within AFS.
	#
	# This code has been optimized to run as quickly as possible.
	# Since it is being invoked only at the beginning of the
	# session, and prior to the inclusion of any of the user's
	# other dotfiles, we can assume that the current directory
	# is the user's home directory.  Also, to avoid having the
	# shell re-evaluate the current contents of the directory,
	# we help it by resetting its "cwd" variable.  We do error
	# checking just in case the path somehow disappears.

	set x=`/bin/pwd`
	if ("$x" != "") then
		set home=$x cwd=$x
	endif
	unset x

	# Special version of add alias that will work in your ~/.environment
	# file.  This is replaced further down with the version that works
	# when you are logged in.

	# This "extend" alias and friends have been left in for backwards
	# compatibility with old .environment files, just in case. The new
	# add alias does not use them.
	alias extend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) set extendyes && \\
	if ($?extendyes && $?verboseadd) echo \!:2 added to end of \$\!:1 && \\
	if ($?extendyes) setenv \!:1 ${\!:1}:\!:2 && \\
	unset extendyes'
	alias sextend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) set extendyes && \\
	if ($?extendyes && $?verboseadd) echo \!:2 added to end of \$\!:1 && \\
	if ($?extendyes) set \!:1=(${\!:1} \!:2) && \\
	unset extendyes'
	alias textend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) set extendyes && \\
	if ($?extendyes && $?verboseadd) echo \!:2 added to end of \$\!:1 && \\
	if ($?extendyes) set \!:1=${\!:1}:\!:2 && \\
	unset extendyes'

	alias add 'set add_opts = (-e \!:*); source $initdir/add'

	# Run user environment customizations identified in your ~/.environment
	# file.  This is the place to include your own environment variables,
	# attach commands, and other system wide setup commands.  You can also
	# cancel default behaviors listed above with "unsetenv" or "setenv".
	# ~/.environment is not sourced if NOCALLS is set (i.e., if 
	# you selected the xlogin "Ignore your customizations" option
	# when you logged in). 

        if ((! $?NOCALLS) && (-r ~/.environment)) source ~/.environment
	
	# remove temporary version of add
	unalias extend sextend textend add
	alias add 'echo Use add in your ~/.environment, not your ~/.path.'

	# Set up default search path, if not yet set.  Use your ~/.path file
	# to provide an alternative path -- this file should be of the form
	# "set path=...", and can refer to the shell variable $athena_path,
	# defined above. The ~/.path file should list a complete path, since 
	# the path identified there will be used INSTEAD of the default path, 
	# not appended.  ~/.path is not sourced if the xlogin "Ignore your
	# customizations" option was selected to begin the session.

	if ((! $?NOCALLS) && (-r ~/.path)) then
		source ~/.path				# User-specified path
	else
		set path=($HOME/$bindir $athena_path .)	# Standard Athena path
	endif

endif
	


# *******************  C SHELL SETUP   *******************

# Set up standard C shell initializations

set noclobber			# Don't overwrite files with redirection

if ($?prompt) then		# For interactive shells only (i.e., NOT rsh):
    set prompt = "athena% "	#   Set prompt
    set history = 20		#   Number of commands saved as history
    set cdpath = (~)		#   Path to search for directory changes
    set interactive		#   Provide shell variable for compatability
endif


# Set up standard C shell aliases

#   alias for re-establishing authentication
alias renew 'kinit $USER && fsid -a && zctl load /dev/null'

#   alias for a convenient way to change terminal type
alias term 'set noglob; unsetenv TERMCAP; eval `tset -s -I -Q \!*`'

#   aliases dealing with mail
alias mail 'Mail'
alias Mail 'more /usr/prototype_user/README.mail ; echo \!* > /dev/null'

#   aliases dealing with x window system
alias xresize 'set noglob; eval `resize` || unset noglob'	# xresize

if ($?XSESSION) then
    if ("$XSESSION" == "") then
	alias logout	'exit && end_session'		# logout for X
    else
	alias logout	'exit && kill -HUP $XSESSION'	# logout for X
    endif
endif

#   aliases dealing with adding locker programs
#   extend remains for other software; add no longer uses the extend alias
alias extend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) set extendyes && \\
	if ($?extendyes && $?verboseadd) echo \!:2 added to end of \$\!:1 && \\
	if ($?extendyes) setenv \!:1 ${\!:1}:\!:2 && \\
	unset extendyes'

alias add 'set add_opts = (\!:*); source $initdir/add'

#   aliases dealing with subjects
alias setup_X '( setenv SUBJECT \!:1 ; ( xterm -title \!* & ) )'
alias setup_tty '( setenv SUBJECT \!* ; csh )'
if ($?XSESSION) then
	alias setup setup_X
else
	alias setup setup_tty
endif
alias remove 'setenv SUBJECT \!* ; source $initdir/env_remove'

# If this is a subject window, run the env_setup script
if (($?SUBJECT) && (-r $initdir/env_setup)) source $initdir/env_setup


# All of the C shell initializing commands above can be overridden by using 
# "unset" or "unalias" commands (or by changing things using "set" or 
# "alias" again) in your ~/.cshrc.mine file, which is sourced here.
# ~/.cshrc.mine is not sourced if the xlogin "Ignore your customizations"
# option was selected to begin the session.

if ((! $?NOCALLS) && (-r ~/.cshrc.mine)) source ~/.cshrc.mine
