if ( $?VERBOSE_INIT ) echo "sourcing $HOME/.aliases..."

# this is sort of my site-independent .cshrc; contains aliases plus a little.
# this will likely only work under a csh variant.

# eek! in fact, 'which' breaks under stock csh.  it hangs indefinitely.
# so, this is basically just wrong, and needs to be fixed.
# (that happens because csh has no 'which,' which is instead a shell script!)


###########################################################################
#
# shell parameters
#

set history=1000		# we want a whole bunch of commands remembered
set savehist=0			# but not between logins
set noclobber			# prevent destructive redirection
				# ( use >! to override )
set ignoreeof			# no ^D logouts
set notify			# tell of bg jobs' completion immediately
set time=5			# tell time of big jobs upon completion
set lineedit			# ^P etc. works

umask 022			# read, ex acess to all
unlimit				# take as much resources as I'm allowed
limit coredumpsize 0		# well, except coredumps, of course.

# other options: autolist, autoexpand, autocorrect, correct=cmd,
# symlinks=expand, listjobs, listlinks

# (path goes at end, in interactive)

###########################################################################
##
## Set up paths to programs (store in env. vars.)
##

set ECHO_PATH = /bin/echo

if ($OS == SunOS) then
    if (-x /usr/local/gnubin/echo) then
        set ECHO_PATH = /usr/local/gnubin/echo
    else if (-x /usr/ucb/echo) then
        set ECHO_PATH = /usr/ucb/echo
    else if (-x /usr/5bin/echo) then
        set ECHO_PATH = /usr/5bin/echo
    endif
    set RLOGIN_PATH = /usr/ucb/rlogin
endif

set RLOGIN_PATH = /usr/bin/rlogin
if ($OS == IRIX  || $OS == IRIX64) then
    set RLOGIN_PATH = /usr/bsd/rlogin
endif

unalias ssh
if ($?tcsh) then
  set SSH_PATH = `which ssh`
else
  set SSH_PATH = `echo no which:`
endif

###########################################################################
##
## Set up env. variables and switches
##

setenv LESS '-d -m -q'
setenv VISUAL emacs

setenv OS `uname -s`


###########################################################################
##
## Alias lots of commands
##

alias cd 'cd \!*;echo $cwd'
alias cp 'cp -i'
alias mv 'mv -i'
alias ls 'ls -aF'
alias lsdir 'ls -aF1 \!* | grep /'
# note bug: if there are no executable files, this version lsexe 
# will do a dir on the current directory(!)
alias lsexe 'dir `find \!* -perm +a+x -not -type d -maxdepth 1`'
# I used to use a -s but I like having more columns
if ($OS == SunOS) then
    # sunos ls needs the -g to be the same, and gnu ls ignores it
    alias dir 'ls -lgaF'
else
    alias dir 'ls -laF'
endif
alias dirt 'dir -rt'
alias dirtail 'dirt \!* | tail'
alias dirsort 'dir \!* | sort -n +4'
alias dirrsort 'dir \!* | sort -rn +4'
unalias rm
alias rmf '/bin/rm -f'
alias rm 'rm -i'
alias rm~ 'rmf *~ .*~'
alias rmlatex 'rmf *~ *.aux *.log'
alias mroe more
alias aliases alias
alias dirs dirs -v
alias mxlookup nslookup -type=mx
alias anylookup nslookup -type=any
alias gohicl 'telnet 9.2.16.86; hosttitle'
alias gohocket 'telnet 9.2.17.36; hosttitle'
alias goferrari 'telnet 9.2.17.46; hosttitle'
alias gocurie 'telnet 9.2.220.66; hosttitle'
alias gof 'rlogin frank.harvard.edu -8 -l galperin'
alias goctc 'rlogin splogin.tc.cornell.edu -8 -l galperin'
alias goanl 'rlogin clyde.mcs.anl.gov -8 -l galperin'
alias ftpanl 'ftp clyde.mcs.anl.gov'
alias duat 'telnet duat.gtefsd.com'
alias weather 'weather \!* | more'
alias fweather "finger weather@cirrus.mit.edu|sed -e 2,37d | awk '{if(NF>0||last>0) print; last=NF}'|more"
alias gow 'ftp wuarchive.wustl.edu'
alias gow2 'ftp archive.orst.edu'
alias goarch 'telnet archie.rutgers.edu'
alias goarch2 'telnet quiche.cs.mcgill.ca'
alias archie 'archie -s'
alias goweather telnet downwind.sprl.umich.edu 3000
alias goneuro ftp ftp.cis.ohio-state.edu
alias golyrics ftp ftp.uwp.edu
alias golyrics2 ftp ftp.luth.se
alias lyrics waissearch -h cs.uwp.edu -d lyrics -p 210
alias gofibs telnet fraggel65.mdstud.chalmers.se 4321
if (! -x ~/bin/newbant) then
    alias newbant $SSH_PATH athena-express.dialup.mit.edu newbant
endif
if (! -x ~/bin/rmbant) then
    alias rmbant $SSH_PATH athena-express.dialup.mit.edu rmbant
endif
if (! -x ~/bin/lsbant) then
    alias lsbant $SSH_PATH athena-express.dialup.mit.edu lsbant
endif
alias gfinger gfinger -b
alias mpeg_play mpeg_play -dither color -quality on
alias goboo rlogin boo-berry.ai.mit.edu -8 -l grg
alias ftpboo ftp boo-berry.ai.mit.edu
alias gosky rlogin skydive.ai.mit.edu -8 -l grg
alias ftpsky ftp skydive.ai.mit.edu
alias setsky setenv DISPLAY skydive.ai.mit.edu:0.0
alias wsort 'w | sort -r +3'
alias psg 'ps auwx|head -1; ps auwx|grep -i '
alias psl 'ps alwx|head -1; ps alwx|grep -i '
alias eset 'eval `tset -s \!*`'
alias gprof gprof -b -E mcount -E _mcount -E __mcount -E mcleanup
alias text 'unsetenv DISPLAY; eset vt100'
alias telm 'text; elm'
alias killelm 'kill -USR1 `ps | grep elm | grep -v grep | awk '\''{print $1}'\''`'
alias fingertail 'grep finger /var/adm/messages | tail'
alias gofast 'renice -19 $$'
alias treno treno -v -Da 40
alias stealth-netscape 'xhost wh; $SSH_PATH wh "netscape4 -display skydive:0.0 >&/dev/null </dev/null &"'
alias dical 'ical -display diuretic:0.0 &'
alias godzilla 'finger polina|grep -i mail; $SSH_PATH genie -l polina' # for polina
alias hosttitle '$ECHO_PATH -n "\033]2;${HOST}\007"'
alias dmalloc 'eval `\dmalloc -C \!*`'
alias xnote 'xmessage \!* -fn -adobe-courier-bold-o-normal--34-240-100-100-m-200-iso8859-1'


# I love shell syntax!
alias dotstamp '(cd; dir .aliases .cshrc .emacs .login .fvwm*[^~] .mailcap .mailrc .mime.types .path .tcshrc .xinitrc | awk '"'"'{system("md5sum " $9"|awk '"'"'"'"'"'"'"'"'{printf $1}'"'"'"'"'"'"'"'"'"); printf(" %9d %3s %2d %5s ",$5,$6,$7,$8);print $9 }'"')"


###########################################################################
#
# interactive helpers
#

if ( $?prompt ) then
    set prompt = "`hostname`[\!]"
endif


# if we're on an xterm and this is an interactive session
if ($?TERM) then
    if (("$TERM" == "xterm" || "$TERM" == "aixterm") && $?prompt) then
        # Display the host name as the window title now, and after exiting too.
	# This covers both hosts which don't have titling enabled, and
	# resetting when it comes back to this host.
        $ECHO_PATH -n "\033]2;${HOST}\007"
        alias rlogin '$RLOGIN_PATH -8 \!*; $ECHO_PATH -n "\033]2;${HOST}\007"'
        alias ssh '$SSH_PATH \!*; $ECHO_PATH -n "\033]2;${HOST}\007"'
    endif
endif

# linux stuff
if ($OS == Linux) then
    alias ftp ncftp
    alias ghostview ghostview -magstep 1 -quiet
    alias xdvi xdvi -s 3
    alias hostname hostname --short
else if ($OS == SunOS) then
    alias whois whois -h rs.internic.net
endif
