|
alias
Create an alias, aliases allow a string to be substituted for a word when it
is used as the first word of a simple command.
SYNTAX alias [name [wordlist]] Without arguments, prints all aliases. With name, prints the alias for name. With name and wordlist, assigns wordlist as the alias of name. wordlist is command and filename substi- tuted. name may not be `alias' or `unalias'. unalias pattern Removes all aliases whose names match pattern. `unalias *' thus removes all aliases. It is not an error for nothing to be unaliased.
If arguments are supplied, an alias is defined for each name whose value is
given.
If no value is given, `alias' will print the current value of the alias.
Alias substitution
The shell maintains a list of aliases which can be set, unset and printed by
the alias and unalias commands. After a command line is parsed into simple commands
the first word of each command, left-to-right, is checked to see if it has an
alias. If so, the first word is replaced by the alias. If the alias contains
a history reference, it undergoes History substitution (q.v.) as though the
original command were the previous input line. If the alias does not contain
a history reference, the argument list is left untouched.
Thus if the alias for `ls' were `ls -l' the command `ls /usr' would become `ls -l /usr', the argument list here being undisturbed. If the alias for `lookup' were `grep !^ /etc/passwd' then `lookup bill' would become `grep bill /etc/passwd'. Aliases can be used to introduce parser metasyntax. For example, `alias print 'pr \!* | lpr'' defines a `command' (`print') which pr's its arguments to the line printer.
Alias substitution is repeated until the first word of the command has no alias.
If an alias substitution does not change the first word (as in the previous
example) it is flagged to prevent a loop. Other loops are detected and cause
an error.
Examples
Create an alias 'ls' that will actually run 'ls -F' alias ls 'ls -F'
Produce a custom prompt to display which machine you are on, the current folder, and the number of the current command: alias cd 'cd \!*; set currDir = `basename $cwd`; set currDir = `echo "<${host}:"$currDir " ! >"`; set prompt = "${currDir} "' cd $cwd <Mac_One:Sheppard 15 >
Making an alias permanent:
Use your favorite text editor to open ~/Library/init/tcsh/aliases.mine and
add your alias commands.
You can also use ~/.tcshrc or ~/.cshrc or if running BASH then
create a .bash_aliases file.
`alias' is a tcsh shell command.
"If you want a picture of the future, imagine a boot stamping on a human
face - forever" - George
Orwell (alias Eric Blair)
Related commands:
env - Display, set, or remove environment
variables
echo - Display message on screen
set - Set a shell variable = value
setenv - Set an environment variable = value
shift - Shift positional parameters
Equivalent BASH command:
alias - Create an alias