# Global cshrc file
#
# $Id: cshrc,v 1.9 1998/06/18 15:17:03 nathanw Exp $

# 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/X11R6/bin /usr/bin \
		  /bin /usr/andrew/bin /usr/athena/etc /usr/sbin /sbin \
		  /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):
set hosttype=linux
set bindir=${hosttype}bin

# Set standard path of directories for man command to search:
set athena_manpath=/usr/local/man:/usr/athena/man:/usr/X11R6/man:/usr/man:/usr/share/man:/usr/andrew/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
	setenv MORE -csd	  		# Default "more" behavior
	setenv EDITOR emacs			# Set default editor
	setenv VISUAL emacs			# Set default screen editor
	setenv NOMHNPROC			# Disable mh MIME support
	setenv MANPATH "$athena_manpath"

	setenv ATHENA_SYS `/bin/athena/machtype -S`
	if ( $ATHENA_SYS == "" ) then
		setenv ATHENA_SYS @sys
	endif
	setenv ATHENA_SYS_COMPAT `/bin/athena/machtype -C`

	if ( ! $?PRINTER && -e /var/athena/clusterinfo ) then
	  setenv PRINTER `awk '/LPR/ { print $3 }' /var/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 'eval `/bin/athena/attach -Padd -P "$athena_path" \!:*`'

	# 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.'

	# Reset athena_manpath in case .path uses it (.path should just use
	# $MANPATH, but using $athena_manpath has worked historically).
	set athena_manpath=$MANPATH

	# 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

	# Make sure applications can properly find their appdefs, etc.

	if (! $?XUSERFILESEARCHPATH) then
	  setenv XUSERFILESEARCHPATH "/usr/athena/lib/X11/app-defaults/%N"
	else
	  setenv XUSERFILESEARCHPATH "${XUSERFILESEARCHPATH}:/usr/athena/lib/X11/app-defaults/%N"
	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 -c` || unset noglob'

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'

set add_flags
alias add 'eval `/bin/athena/attach -Padd $add_flags \!:*`'

#   aliases dealing with subjects
alias setup_X '( setenv SUBJECT \!:1 ; ( xterm -title \!* & ) )'
alias setup_tty '( setenv SUBJECT \!* ; $SHELL )'
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
