Topic: Alias

SYNTAX:  alias [alias] [text]

alias                         List all aliases
alias [alias]                  List only the one alias
alias [alias] [text]           Add a new alias definition
The 'alias' command allows you to abbreviate certain commands as 
something much shorter, and to list your aliases, with syntax as
specified above.  The 'ralias' command must be used to remove
aliases from your alias list.

alias tb tell barney

Then, if you were talking to barney frequently you could type:

tb hi!

instead of:  tell barney hi!

Also what you can do with aliases is command line replacement, using
the designators $1, $2, etc, and $* you can replace commands within
a command string rather than just at the end.

alias pb put $1 in bag

would allow you to type:  pb ring

and that would put the ring in the bag.

The # following the $ is the position of the argument on the command
line that you want to function as the replacement.  $1 is the first
argument, $2 is the second...


alias tph tell $1 I'm dying! I have $2 hit points left!

Then you could type:  tph barney 12

And it would tell barney:  I'm dying! I have 12 hit points left!

In the example above about bags, the example given will work, however
you're more likely going to want $* instead of $1.  $* is a special
case that means to substitute EVERY argument in that place.
Since some items are two words, and often you want 'ring 2', for instance,
those are treated as 2 separate arguments, and $1 would only get the first.
 $* will get every argument, allowing you to type:

pb black sword 3

The new alias would be: alias pb put $* in bag

$* is also the 'superset' of the arguments, so you can NOT combine it
with any of the other $ variables ($1, $2.. etc)

Aliases allow a wide range of special metacharacters to be
used which are substituted with supplied text when the alias is
used.  The special symbols are:

$*      All the arguments supplied to the alias (eg for the command
        'g all from bag' $* would be 'all from bag').
$n      The nth argument supplied to the alias (eg $2 from 'g all
        from bag' would be 'from').
$n-     The nth argument onwards ($2- for 'put potion in sack' is
        'in sack').
$m-n    The mth through nth arguments (for 'give silver key to
        man' $2-3 is 'silver key').

Note that if there are only 4 arguments to an alias and you type
more than four, the additional arguments will be appended.  For example,
'alias la look at' will still let you 'la board'.

Also, aliases cannot be nested.  If after an alias substitution
is done, the verb is an alias it won't be substituted again.
Common aliasing problems involve accidental aliasing of rather
important commands.  You should be very careful when you create aliases
that you don't do things like:  alias cast ball fireball as entering
'cast ball'  will result in an attempt to 'ball fireball ball' and
any other command that starts with 'cast' will also fail.

It is also a particularly bad idea to 'loop' aliases, for example
you do not want to do this:

alias get get all

That causes the alias to loop on 'get'.

Nor do you want to do this:

alias look examine
alias examine look

Finally, if you're having problems with commands suddenly not working
anymore, please check your alias or nickname list before confronting
a wizard--your problem often lies therein.

See also: rnickname, nickname, ralias, login

Close Window