#  Startup.csh Release 2.2.28 for Windows NT and Windows95 (Chicago)

#  This is a sample startup.csh file.  Hamilton C shell looks for this
#  file in your home directory every time you start a new copy whether
#  from the Program Manager or from the command line.  You should edit
#  this file to customize it to your needs, in particular to add any
#  alias definitions you always want available each time you start
#  the shell.  Blank lines are ignored; text following a "#" on a given
#  line is considered a comment.

#  Paste the current directory onto the front of the search path if it's
#  not already there.  (If you're satisfied you've already set the path
#  variable to start with "." through regedit, you can delete this step.)
if (path[0] != ".") set path = . $path

#  Useful constant.
@     pi       = 3.1415926535897932384626433

#  Aliases to allow these functions to be used under cmd.exe albeit
#  under different names.  (Date and vol conflict with cmd.exe builtins.)
alias date     dt
alias vol      vl

#  NT 3.1 didn't allow any directories to be placed ahead of the system
#  defaults in a user's search path thru the Control Panel (where naturally,
#  you'd want to set it), so to override the standard more and label and
#  the NT SDK rm commands (without actually deleting them), we've given
#  the Hamilton versions different names and used the alias facility instead.
alias more     hmore
alias label    hlabel
alias rm       hrm

#  If we're running under Windows95 (Chicago), alias cmd to be command.com.
if (`whereis cmd.exe` == '') alias cmd command.com

#  Aliases to simulate cmd.exe builtins.
alias md       mkdir
alias pause    (echo -n Press any key when ready ...; @ getchar; echo)
alias rd       rmdir
alias start    cmd /c start
alias type     cat

#  Aliases and procedures for intercepting copy, xcopy and rename commands so
#  that wildcarding won't be done before they're called.
proc safecopy(files)
   cmd /c copy $files; @ nowild = s; unlocal s
end
alias copy     (local s; @ s = ^$nowild; @ nowild = 1; safecopy)
proc safexcopy(files)
   xcopy.exe $files; @ nowild = s; unlocal s
end
alias xcopy    (local s; @ s = ^$nowild; @ nowild = 1; safexcopy)
proc saferename(files)
   cmd /c rename $files; @ nowild = s; unlocal s
end
alias rename   (local s; @ s = ^$nowild; @ nowild = 1; saferename)
alias ren      rename

#  Intercept the dir command either with a simple alias (letting the C shell
#  do the wildcarding first) or with the same kind of alias + proc mechanism
#  used above to turn off wildcarding first.  (Dir behaves differently
#  depending on whether you let it do its own wildcarding or not.)

#  Uncomment either the simple alias to let the C shell do the wildcarding:
alias dir      cmd /c dir

#  or the following 4 lines to have dir work exactly like under cmd.exe:
#  proc safedir(files)
#     cmd /c dir $files; @ nowild = s; unlocal s
#  end
#  alias dir      (local s; @ s = ^$nowild; @ nowild = 1; safedir)

#  Intercept the del command so "del *.*" still gives the "Are you sure?"
#  message.  (Alternately, you may prefer to simply alias it to rm.exe.)
proc safedel(files)
   cmd /c del $files; @ nowild = s; unlocal s
end
alias del      (local s; @ s = ^$nowild; @ nowild = 1; safedel)
alias erase    del

#  Provide a help mechanism that can give either
#     a) The Win32 error message corresponding to a specified error code or
#        (if no code number is given) the status from the last command, or
#     b) Help for a specified NT command.

proc help(errno)
   if ($#errno == 0) @ errno = status
   if (isnumber(errno[0])) then
      winerror $errno   #  winerror is in the samples directory with source.
   else
      help.exe $errno
   end
end

#  Aliases to implement obsolete Unix C shell reserved words.  (You may
#  not want these unless you have old habits.)
alias breaksw  break
alias endif    end
alias endsw    end

#  Typical locally-defined aliases.  (Edit this section to define your own.)

alias di       diff -b!    #  "Diff interactive":  Merged diff using color to
                           #     show changes.  Ignore white space differences.
alias duc      du -c       #  Disk usage for the current disk only.
alias beep     eval echo -n ^^a  #  Beep! (eval is used with an extra ^ so
                                 #     just listing aliases won't beep at you.)
alias mi       more -i     #  "More interactive":  Clear screen first for
                           #     speed.  Don't exit if less than a screenful.
alias f        fgrep       #  Faster name for fgrep.
alias fn       fgrep -n    #  Fgrep and print line numbers.
alias g        grep        #  Faster name for grep.
alias h        history
alias cdd      cd +c       #  Change directory AND disk.
alias home     cdd ~       #  Change to the home directory and disk.
alias q        exit
alias ll       ls -L       #  Long listing of the directory.
alias ld       ls -a +D -. #  List only the subdirectories.
alias app      (cat >>)    #  Append stdin to a file.
alias loadhist source -n ~\history.csh
alias dumphist (history -s >~\history.csh)
alias w        ((wait;beep))  #  Wait for background processes and beep.
alias rot13    tr 'n-za-mN-ZA-M' 'a-zA-Z'    #  Encoder/Decoder for off-
                                             #  color jokes on Internet.

#  If you like, count the nesting level of this invocation of csh.exe
#  and put it into the prompt of nested invocations.
if (! $?did_setlayer) then
   if ($?layer) then
      @        layer++
      set      prompt1 = '[$layer] $@ $CDISK% '
      set      prompt2 = '[$layer] $@ $CDISK? '
   else
      setenv   layer = 1
   end
   @  did_setlayer = 1
end
