if (-e /util/etc/.cshrc) source /util/etc/.cshrc

if !($?HOSTTYPE) setenv HOSTTYPE `arch`

set path=(/web/tech-reports/admin/bin $path)

umask 022

setenv PRINTER groucho
setenv LPDEST groucho

if (! $?prompt) exit #exit at this point if not interactive shell

# machine or server I am logged in from
if (! $?REMOTEHOST) then
  setenv WHERELONG `who am i|sed -n -e 's/.*(\([^.]*\))/\1/p' -e 's/.*(//' -e 's/).*//' -e 's/\.cs\..*/.cs@/p' -e 's/\.cc\..*/.cc@/p' -e 's/\.acs.*/.acsu@/p' -e 's/\.cit.*/.cit@/p' -e 's/^128\./128\./p' | sed 's/@/.buffalo.edu/'`
  if ($WHERELONG == '') setenv WHERELONG unix
else
# Rather use tcsh 6.05's REMOTEHOST envariable
  setenv WHERELONG $REMOTEHOST
endif

setenv WHERE `echo $WHERELONG|sed -e 's/\..*//'`


# set the DISPLAY variable only if logged in from workstation
if (!($?DISPLAY) && (`echo $WHERE|egrep -e 'unix|ubvms|hadar|pegasus|hydra|talos|castor|electra|autarch|lictor|vodalus|conciliator|armstrong|gagarin|annex|tsx'` == "")) setenv DISPLAY {$WHERELONG}:0

if (`hostname` == $WHERELONG) setenv DISPLAY :0

# if the variable host is undefined, define it now
if (! $?host )then
	if (`whoami` == $user) then
		set host = "`hostname | sed 's/\..*//'`"
	else
		set host = "`whoami`@`hostname`"
	endif
endif

setenv VISUAL vi
setenv EDITOR vi

if (-e /util/bin/less) then
  setenv PAGER less
else
  setenv PAGER more
endif

setenv LESS -Mdiz-2
setenv LESSCHARSET latin1
setenv XRSH_AUTH_TYPE none
setenv XTERMMOUSE y
setenv ATTRIBUTION "%)f <%>f> wrote:"
stty crterase crt erase '^?' kill '^U' intr '^C'
set filec addslash notify autolist printexitvalue autocorrect 
set fignore=(.o .i) correct=cmd symlinks=expand history=2048 
set savehist=(512 merge)
endif
unset noclobber autologout
set temp = 1
if ($?tcsh) then
  set temp = $tcsh:r
endif
if ($?tcsh && $temp:r > 5) then
  unset temp
  set prompt = "techreps:%m {%/} % "
  alias pu pushd
  alias po popd
else
  alias sp 'set prompt="$host {$cwd:t} % "'
  alias cd 'cd \!*;sp' 
  sp
  alias pu 'pushd \!*;sp'
  alias po 'popd \!*;sp'
endif

alias ls 'ls -F'			# to make ls nice.
alias ls-l ls -l			# because I can't type!

alias read $PAGER README                # to read README files easier
alias xread xless README                # to read README files under X
alias m $PAGER				# useful shorthand
alias zm zmore				# useful shorthand
alias r reply				# useful shorthand

# format some commands
alias up 'uptime'			# uptime on all machines in load order

alias send 'send -n'			# don't ever use mail to send.
alias reply 'reply -n'			# nor to reply
alias f 'finger -m'			# let f just look up usernames
					#   (and call finger to solve SunOS)

alias ci ci -l				# Have ci leave a copy checked out

# job control stuff
alias j jobs -l                         #to see what jobs I've stopped with ^Z
alias 1 %1
alias 2 %2                              # the most stopped jobs I'll have
alias 3 %3
alias 4 %4
alias 5 %5
alias 6 %6
alias 7 %7
alias 8 %8
alias 9 %9
alias k kill -9

alias setdisp 'disp $WHERELONG'
alias setdisp1 'disp1 $WHERELONG'
alias setdisp2 'disp2 $WHERELONG'
alias setdisp3 'disp3 $WHERELONG'
alias undisp 'unsetenv DISPLAY'
alias showdisp 'printenv DISPLAY'

alias xauthto 'xauth extract - $DISPLAY | rsh \!* xauth merge -'
alias xinit 'mkcookie; \xinit -- -auth .Xauthority ; kbd_mode -a; clear_colormap'
alias xdvi xdvi -s 4 -S 20 
alias xdv "(xdvi -hushspecials -name '\!\!:1 : xdvi' -geometry +165+30 \!*&)"
alias gv "(ghostview -geometry +165+30 -mag -1 \!*& )"

alias xless '(xterm +sb -title "\!:1" -geometry 80x50 -ut -e less \!* &)'
alias xvi '(xterm +sb -title \!:1 -geometry 80x50 -ut -e vi -c ":map  " \!* &)'
alias xvim '(xterm +sb -title \!:1 -geometry 80x50 -ut -e vim -c ":map  " \!* &)'

# some logoff commands
alias lo 'clear;logout'

if ($HOSTTYPE == sun3 || $HOSTTYPE == sun4) alias ping ping -s

alias quota quota -v
alias cp cp -p
alias rcp rcp -p

alias title 'echo "@]0;\!*" | sed "s/@//"'
alias titleicon 'echo "@]1;\!*" | sed "s/@//"'
alias titlebar 'echo "@]2;\!*" | sed "s/@//"'
alias font 'echo "@]50;\!*" | sed "s/@//"'
