See the UNIX Programmers Manual or via % man csh
% alias rm '/bin/rm -i \!* '
make the rm command default to interactive mode (-i) in order to
prevent catastrophes caused by 'rm *' which silently deletes ALL FILES.
% alias
will list all the defined aliases.
% alias list 'pwd ; ls -adF .* *'
displays the name of the current directory, followed by the names of
all files in the current directory, (-ad). The (-F) causes
'/' to be suffixed to the names of directory files,
'*' to be suffixed to the names of executable files
'=' to be suffixed to the names of sockets
'@' to be suffixed to the names of symbolic links
% alias go 'cd \!* ; list'
changes directory, runs list, if 'list' was aliased prior to this.
WARNING: beware of alias loops such as: alias ls 'ls -F'
% alias back 'cd ..'
changes the current directory to become the directory before the current
directory (the .. means the parent directory).
% alias joel 'echo \!$; echo \!^'
swaps the first and last arguments and lists them.
Alias does not support a mechanism for determining a single argument
other than "the first argument" and "the last argument",
\!^ and \!$ respectively. "All arguments" is specified by the \!* string.
(See examples below for a way to get at specific arguments).
% alias doit 'set args = (\!*); echo $args[2]'
will cause argument two to be echoed whenever 'doit' is invoked.
% alias print123 'echo \!^-3'
will cause arguments one, two and three to be listed whenever 'print123'
is invoked.
From Dave Curry (ihnp4!pur-ee!davy):
alias cd chdir \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd'
alias pd pushd \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd'
alias pp popd \!:\* \; set prompt='${cwd}\[!\]\ ' \; setenv CWD '$cwd'
These put the current directory into the environment also, this is
for an editor used here locally which uses this information. You can delete
that part if you don't need it.
From Greg Noel, NCR Torrey Pines Greg@nosc.ARPA:
Here is something that turns the directory structure from something
passive into something active:
alias come if -e .greg_come source .greg_come
alias go if -e .greg_go source .greg_go
alias cd go \; set prev = \$cwd \; chdir \!\* \; \
echo \$prev ==\\\> \$cwd \; come
What this does is cause the shell to look for a specific file whenever it
transfers into a directory, and if it is there, source it. Also, whenever
you leave a directory, it looks for a different file and sources that before
leaving. I use this to set up location-specific aliases or to have something
happen auto-magically whenever I work in some directory -- for example,
changing into my `play' directory invokes a menu that will set up the
environment and run game programs -- different save files for `rogue' or
other stuff that I don't want to carry around with me all the time.
It's more flexible than it seems at first glance; the only thing I can
suggest is to try it and you will keep finding new ways to use it.