8.7. AliasesThe C shell allows you to create and customize your own commands by using the built-in command alias (Figure 8-14).
Here's an example of alias in action: $ alias dir 'ls -aF' ...register an alias. $ dir ...same as typing "ls -aF". ./ main2.c p.reverse.c reverse.h ../ main2.o palindrome.c reverse.old $ dir *.c ...same as typing "ls -aF *.c". main2.c p.reverse.c palindrome.c $ alias dir ...look at the value associated with "dir". ls -aF $ _ In the following example, I aliased a word in terms of itself: % alias ls 'ls -aF' ...define "ls" in terms of itself. % ls *.c ...same as typing "ls -aF *.c". main2.c p.reverse.c palindrome.c % alias dir 'ls' ...define "dir" in terms of "ls". % dir ...same as typing "ls -aF". ./ main2.c p.reverse.c reverse.h ../ main2.o palindrome.c reverse.old % alias who 'date; who' ...infinite loop problem. % who Alias loop. % alias who 'date; /usr/bin/who' ...full path avoids error % who ...works fine now. Fri May 13 23:33:37 CST 2005 glass ttyp0 Feb 13 23:30 (xyplex2) % _ 8.7.1. Removing an AliasTo remove an alias, use the built-in command unalias (Figure 8-15).
8.7.2. Useful AliasesFigure 8-16 is a list of the useful aliases that I keep in my ".tcshrc" file, together with a brief description.
8.7.3. Sharing AliasesTo make an alias available to a subshell, place its definition in the shell's ".tcshrc" file. 8.7.4. Parameterized AliasesAn alias may refer to arguments in the original pre-aliased command by using the history mechanism described in the next section. The pre-aliased command is treated as if it were the previous command. The useful alias for cd that I mentioned in the previous section makes good use of this facility; the \!* part of the alias is replaced by all of the arguments in the pre-aliased command. The ! is preceded by a \ to inhibit its special meaning during the assignment of the alias: alias cd 'cd \!*; set prompt = "$cwd \! > "; ls' |