#!/bin/tcsh -f
#
#
#  This file should be "source"d by your shell
# in order to get access to the setup facilities
#

# Location of setup scripts
setenv SETUP_SCRIPTS ${HOME}/setups/csh

# Create setup alias for setting up different packages
# This will either source the specified file if it exists
# or the USAGE file if not. The \!:* represents the
# arguments given to the alias. We use this instead of
# \!:1 (i.e. the first argument) since this way, no error
# is printed if setup is run without arguments
alias setup 'if ( -f ${SETUP_SCRIPTS}/\!:* ) source ${SETUP_SCRIPTS}/\!:* ; if ( ! -f ${SETUP_SCRIPTS}/\!:* ) source ${SETUP_SCRIPTS}/USAGE'


# alias for easily filtering out duplicates in a
# PATH-like environment variable. This is done as
# an alias so it can affect the caller's environment.
# In case you are interested, here's a breakdown of
# what the characters in "$?\!:*" are for:
#
#  $?    - checking if an environment variable is set
#  \!:1  - c-shell syntax for arguments passed into alias
#          the "\" is to escape the "!" so it is not
#          interpreted until the alias is executed. The
#          "1" indicates the first argument (i.e. the
#          environment variable name). The "\!:*" indicates
#          all arguments.
#
#  One big drawback of this is that if the command fails
# (e.g. if no arguments are given) then a somewhat cryptic
# message will be printed that will be almost completely 
# un-helpful to the user.
alias filter_path 'if ( $?\!:1 ) setenv \!:1 `${SETUP_SCRIPTS}/../filter_path \!:*`'
