Usage
Default startup.csh
Overriding the default
See also
The C shell always looks for a startup.csh file unless it's started with -f or -F indicating fast startup. The search order is to look first in the user’s ~ home directory, then in the C shell’s distribution directory for the default.
Because login.csh is useful for setting up environment variables, login.csh is read before startup.csh.
startup.csh is useful for defining settings that aren't inherited from parent to child process copies of the C shell, including definitions for useful aliases and procedures.
This is the default startup.csh file in the distribution directory.
# Hamilton C shell(tm) 2012 # Startup.csh Release 5.2 # This is the default startup.csh file. Hamilton C shell looks for # this file first in your home directory and then in its distribution # directory every time you start a new copy. # You can override this by creating your own startup.csh in your home # directory. If all you'd like to do is add your own additional # statements, the easiest way to do that is to source this default # startup.csh file at the start of the one in your home directory: # # source $shell:h:h\startup.csh # Blank lines are ignored; anything following a "#" on a given line is # considered a comment. # 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 # Aliases to access the Hamilton versions of more, label, rm # and sort, still allowing use of the Windows more.com, label.exe # and sort.exe utilities if referred to with the .com or .exe # extension. alias more hmore alias label hlabel alias rm hrm alias sort hsort # If we're running under Windows95, alias cmd to be command.com. if (`whereis cmd.exe` == '') alias cmd command.com # Aliases to simulate cmd.exe builtins. alias assoc cmd /c '"assoc ^!^*"' alias ftype cmd /c '"ftype ^!^*"' alias md mkdir alias pause (echo -n Press any key when ready ...; @ getchar; echo) alias rd rmdir alias start env -N 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 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 # 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) # Aliases to run the Vim editors, using env to delete the SHELL variable # from the environment Vim inherits. Vim only knows how to use cmd.exe # to "shell out" via the :! commands and gets confused if the SHELL # variable is defined. alias vim env -D SHELL= vim.exe alias gvim env -D SHELL= gvim.exe # 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 # Pre-defined aliases. alias app (cat >>) # Append stdin to a file. alias beep eval echo -n ^^a # Beep! (eval is used with an extra ^ so # just listing aliases won't beep at you.) alias cdd cd +c # Change directory AND disk. 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 f fgrep # Faster name for fgrep. alias fi fgrep -i # fgrep, case-independent. alias fn fgrep -n # Fgrep and print line numbers. alias g grep # Faster name for grep. alias gi grep -i # Grep, case-independent. alias h history alias home cdd ~ # Change to the home directory and disk. alias killp (kill -x! ^`pss ^!^*^`:0) # Kill any matching processes. alias ll ls -L # Long listing of the directory. alias ld ls -a +D -. # List only the subdirectories. alias ldr ls -Ldr # Long listing, recursive, sorted by date. alias loadhist source -n ~\history.csh alias dumphist (history -s >~\history.csh) alias mi more -i # "More interactive": Clear screen first for # speed. Don't exit if less than a screenful. alias po popd # Pop the directory stack. alias pss (ps -s | fi ^!^*) # List any matching processes alias pu pushd # Push a new directory onto the stack. alias q exit alias ro rotd # Rotate the directory stack. alias rot13 tr 'n-za-mN-ZA-M' 'a-zA-Z' # Encoder/Decoder for off- # color jokes on Internet. alias su env -D LAYER= su.exe # Don't pass the prompt LAYER variable # to su to avoid it showing up in the # elevated prompt in the new window. alias sudo su -. alias uud uudecode alias uue uuencode -c # uuencode using cp-style syntax. alias w ((wait;beep)) # Wait for background processes and beep. # Set f1 to open the user guide. setkey f1 open ^$shell:h:h\UserGuide\index.htm # Count the nesting level of this invocation of csh.exe # and put it into the prompt of nested invocations. if ($?LAYER) then @ LAYER++ set prompt1 = '[$LAYER] $@ $CDISK% ' set prompt2 = '[$LAYER] $@ $CDISK? ' else setenv LAYER = 1 end # Ensure that each level sets its own title. unsetenv CshTitle set history 2000 # Bump up the size of the history list. |
The C shell runs the default startup.csh only if you don't have one in your HOME directory. So the easiest way to easiest way to override the default is to create a startup.csh in that directory and put whatever you like in it, including copying and pasting only just those parts of the default startup.csh you like.
If you mostly like the default startup.csh but would add or change only a few things, source the default startup.csh, then add your changes. For example, if you like some but not all of the predefined aliases and procedures it contains, you could unalias or unproc the ones you don't like.
Here's how to source the default startup.csh file without having to know where it is.
The $shell variable returns the filename of the C shell executable that's running, e.g., C:\Program Files\Hamilton C shell 2012 x64\Bin\csh.exe. The :h editing operator returns the parent directory. $shell:h:h is the root of C shell's install directory, C:\Program Files\Hamilton C shell 2012 x64.
Login.csh
Customizing the shell
C shell command line options
Aliases
Predefined aliases
Procedures
Tutorial: Aliases
Tutorial:Procedures