Aliases

An alias is a string substitution that takes place in the shell. Aliases are used to give personal shorthand strings and to create and customise commands. Because the substitution is provided by the shell, an alias is much quicker than a shell script.

To set up an alias use the alias command.

% alias makepublic 'chmod a+r,o-w'

The shell will now understand the command makepublic. Whenever the command makepublic appears, the shell will replace it with chmod a+r,o-w.

To make an alias take an argument, use the string \!* in the alias definition, for example

% alias ls 'ls -l \!* | more'

Subsequent uses of ls will be replaced by the above string, with the !* replaced with the word that came after ls, for example

% ls /usr/lib
ls -l /usr/lib | more

When the alias is used the string ls /usr/lib will be replaced with ls -l !* | more and then the string !* will be replaced with the arguments from the history of the last command given i.e. ls /usr/lib. In the original alias command !* was preceded with a backslash (\) to escape the usual history meaning of !*

The command alias on its own will list all the currently recognised aliases. The command unalias ls will reset ls back to its original meaning.

Help: for more information see csh(1). Once in the manual pages type /Alias Substitution to search forward through the screens.