#!/bin/csh -v

setenv HOST `hostname`

# Remove the .eece.unm.edu from the hostname.

set shost=`basename $HOST .eece.unm.edu`
if ($HOST == "cougar") then
  set shost = $HOST
endif

umask 002

# if for  Don't do all of this garbage if there isn't a prompt.
if ( $?prompt ) then
 if ($?ENV_NAME == 0) then
   echo ""
   echo "Set up your environment by entering your user name"
   echo "<return> for khaos environment"
   echo ""
   echo -n "enter user name : "
   set env_name = $<
   if ( $env_name == "") then
      set env_name = "khaos"
   endif

   if ( (! ( -e ~khaos/work/dotfiles/.$env_name)) && $env_name != "khaos") then
      echo "dot file $env_name does not exist"
      echo "setting user environment to khaos"
      set env_name = "khaos"
   endif
   setenv ENV_NAME $env_name

   if ( $env_name == "khaos") then

     if ( $shost == "wayback" || $shost == "sirius" || $shost == "pprg" \
          || $shost == "zu" || $shost == "neuron" || $shost == "suraj" ) then
       set path=( . ~khaos/bin /usr/bin/X11 /usr/local/bin \
	          /usr/new /usr/lang /usr/ucb /usr/bin /bin /usr/local/etc \
	          /usr/etc /etc /usr/hosts )
     else if ( $shost == "bullwinkle" || $shost == "natasha" || \
	       $shost == "peabody" || $shost == "snidley" ) then
       set path=( . ~khaos/bin /usr/local/bin /usr/ucb \
	          /usr/new /usr/bin /usr/bin/X11 /bin /usr/local/etc /usr/etc \
	          /etc /usr/hosts )
     else if ( $shost == "rocky" ) then
       set path=( . /research/data4/khaos/bin \
                  ~khaos/bin /usr/local/bin /usr/ucb \
	          /usr/new /usr/bin /usr/bin/X11 /bin /usr/local/etc /usr/etc \
	          /etc /usr/hosts )
     else if ( $shost == "sherman" || \
		$shost == "chama" || $shost == "jemez" || \
		$shost == "borris" || $shost == "nell") then
       set path=( . ~khaos/bin /usr/bin/X11 /usr/openwin/bin /usr/local/bin \
	          /usr/new /usr/ucb /usr/bin /bin /usr/lang /usr/local/etc \
	          /usr/etc /etc /usr/hosts )
     else if ( $shost == "rocknroll" ) then
       set path=( . /research/data2/khaos/bin \
		   /usr/local/bin /usr/new /usr/bin/X11 /usr/ucb /usr/bin \
                   /bin /usr/local/etc /usr/etc /etc /usr/hosts)
     else if ( $shost == "dudley" ) then
       set path=( . /usr/khaos/bin /usr/local/bin /usr/new /usr/bsd /usr/ucb \
		   /usr/bin /usr/bin/X11 /bin /usr/local/etc /usr/etc /etc \
		   /usr/hosts )
     else if ( $shost == "cougar" ) then
       set path=( . /extra2/khaos/bin /usr/local/bin \
             /usr/bin /usr/bin/X11 /bin /usr/local/etc /usr/etc /etc \
             /usr/hosts )
     else 
       set path=( . ~khaos/bin /usr/local/bin /usr/new /usr/ucb /usr/bin \
                   /bin /usr/local/etc /usr/etc /etc /usr/hosts )
     
     endif
      
#       Set all the shell variables.    Set all the aliases.

      set notify
      set history = 40
      set savehist = 40
      source ~khaos/.alias
      source ~khaos/.khoros_env
      set prompt = "khaos% "
   else
      echo ""
      echo "sourcing ~khaos/work/dotfiles/.$env_name"
      echo ""
      source ~khaos/work/dotfiles/.$env_name

   endif
 else
   set env_name = $ENV_NAME
   set env_name = $env_name:t
   if ( $env_name != "khaos") then
      echo ""
      echo "sourcing ~khaos/work/dotfiles/.$env_name"
      echo ""
      source ~khaos/work/dotfiles/.$env_name
   endif
   set notify
   set history = 40
   set savehist = 40
   source ~khaos/.alias
   source ~khaos/.khoros_env
   set prompt = "khaos% "
 endif
else
   source ~khaos/.khoros_env
   set path=( . $KHOROS_HOME/bin /usr/local/bin /usr/new /usr/ucb /usr/bin \
                   /bin /usr/local/etc /usr/etc /etc /usr/hosts )
   if ( ! $?env_name ) then
      set env_name = "khaos"
   endif

endif

# endif for  Don't do all of this garbage if there isn't a prompt.
