Title | Previous | Next

alias

Define or list command aliases.

Synopsis:

alias [ type= type]

alias name

alias command=yes

alias [ command=yes|no ] name "value"

Arguments:

name

An alphanumeric string, starting with a letter.

command

This indicates whether or not the alias is a command. If so, the alias should only be expanded when it appears as a command and not when it appears as a variable name. For example, consider the following alias:

alias ucdmesh "mesh var=ucdmesh1; plot mesh"

In this case, command is equal to yes (the default), so ucdmesh will be treated as a variable when you type " mesh var=ucdmesh ". If " command=no " is added to the above alias, when you type " mesh var=ucdmesh ", the ucdmesh is expanded into the command listed above, and there would be an error.

type

The "category" of aliases to which this alias belongs. By default, aliases for which a type is unspecified are in the "user" category. Other categories include "bdiv", "cale" and "system". Users may also create their own category types. This argument is used to display aliases by category. For example, a user might want to see what all the "cale" aliases are.

" value "

A quoted string containing MeshTV commands.

Description:

With the alias command, you choose a "name" to represent a string of MeshTV commands or aliases.

The alias command works in much the same way as it does under the C-Shell in UNIX TM , where aliases (names) represent other operations. This allows the user to effectively rename existing commands, and to define a single command that executes numerous other commands.

With no arguments, or with just the type option, alias lists various aliases along with their values. By default, the type is "user" if left unspecified, so just typing " alias " will list those aliases created by the user. This is equivalent to typing " alias type=user ". Similarly, other groups of aliases can be listed. For example, to see the system aliases that MeshTV contains, type " alias type=system ". Likewise, to see the cale aliases or the bdiv aliases, type " alias type=cale " or " alias type=bdiv ". Users can also create personal types. For example, if I am working on a project called CoolThing, I can define the following alias: " alias type=CoolThing cool ls " This would create an alias named "cool" that lists my data file. I can now type " alias type=CoolThing " to see all the aliases associated with the CoolThing project.

With one argument, alias prints the value associated with the given name argument. For example, based on the above paragraph, typing " alias cool " would yield a description of the cool alias.

By default, an alias is treated as a command, so the alias name is only expanded when the name occurs as a command and not when it occurs as a variable. Adding " command=no " indicates that the alias is not a command, so it will be expanded whenever it occurs on the command line. Note that if the above cool alias had been " alias type=CoolThing command=no cool ls ", typing " alias cool " would yield an error because cool would be expanded to ls before being passed to the alias command. Since ls isn't an alias, MeshTV would report an error.

Command-only aliases (the default, or those with command=yes in their definition) can expand positional variables. Two kinds of positional variables are allowed, named and numerical. Numerical variables start with 1, and represent the position of the argument. So $1 would be the first numbered argument to the command, and $2 would be the second numbered argument. The positions for the numbered variables do not count named variables. Look at the following example:

alias command=yes pli "iso var=$1 lt=$width"

pli width=2 d

In the above example, $width is a named variable, and $1 is a numbered variable. Even though the "d" is the second argument it fits the $1 variable since it is the first numbered argument. This format allows the user to also type " pli d width=2 "

Examples:

alias command=yes clr "clear" # Define an alias

alias clr # Print alias definition for clr

alias # Print definition of type=user aliases

alias command=no # Include command=no alias definitions

alias command=yes # Print type=user command=yes definitions

alias command=yes type=cale

alias type=system # Print all system aliases

alias plt "plot"

alias command=no type=user ucd "ucdmesh"

alias type=mytype command=yes doit "ls"

alias foo "clr; plt"

alias cplt "clear; plot"

# The following example is read from an init file.

alias type=cale command=yes plv " \

if (defined \"vec_ppp\") \

(error \"The vector plot is already plotted.\") \

(progn \

(delete_vec) \

(alias command=no \"vec_ppp\" yes) \

(set_vec_symm) \

(vec var=$1) \

(plot_vec)) \

";

See Also:

defined , error , if , progn , unalias


Title | Previous | Next

MeshTV@viper.llnl.gov
Copyright © 1998, U.S. Department of Energy. All rights reserved.