The alias command defines a new command name as the specified wordlist, which could be a composite of other commands. That is, wordlist may contain multiple commands separated by semicolons. Subsequent uses of name as a command (at the beginning of a line, following a semicolon, or as a command argument of perframe) will be replaced with wordlist. Aliases are saved in sessions. It may be useful to create aliases automatically at ChimeraX startup by including alias commands in the Startup preferences. For assigning a name to a selection or target specification, see the name command instead. See also: buttonpanel, functionkey, runscript, custom presets
Within wordlist, $1, $2, $3 ... may be used to indicate the first, second, third ... arguments of name. In addition, $$ indicates $ itself, and $* indicates the rest of the line, which allows for variable numbers of arguments. For example, ribbon is aliased to cartoon $*, allowing any of the following to work:
ribbonA string that contains spaces can be designated as a single argument by enclosing it in single or double quotation marks. The quotation marks will be omitted when the alias is expanded. For example,
ribbon #1/A
ribbon #4 suppress false
alias ribcolor color $1 $2 targ cis equivalent to
ribcolor '/a & helix' 'dodger blue'
color /a & helix dodger blue targ c
An example of multiple commands, in this case without arguments:
alias reset view orient; view initial
The definition of a pre-existing alias can be shown with alias name.
The command alias list lists the current user-defined aliases in the Log, whereas alias list internal lists the built-in aliases.
The command alias delete can be used to “forget” a specific alias or all aliases.
alias myzone zone clear; zone $1 $[residueDistance $2$] $[label $3$]; view $1:<8 clip false
myzone /A:12
myzone /A:12 6.5
myzone /A:12 6.5 false
--but not--
myzone /A:12 false
A single optional section may contain multiple arguments, but all of them must be supplied for that part of the command to take effect:
alias myzone zone clear; zone $1 $[residueDistance $2 label $3$]; view $1:<8 clip false
--the following two will work as expected--
myzone /A:12
myzone /A:12 6.5 false
--the following will be accepted, but all optional values ignored!!--
myzone /A:12 6.5
myzone /A:12 false
Note that the zone command is somewhat unusual in that the default distance cutoff is “sticky” within a session (resets to the value most recently used).
The command alias usage sets what information will be shown by the usage command for the specified alias, or by usage aliases for all user-defined aliases. The synopsis option allows supplying a short description. The url option specifies a help page for the alias. The additional options allow assigning names and descriptions for arguments $1, $2, etc. Strings containing spaces should be enclosed in quotation marks. Example:
alias turtle open $1
usage turtle
... gives default usage information in the Log:
turtle $1
— alias of "open $1"
$1: a text string
Changing this information and trying usage again:
alias usage turtle synopsis "open a PDB structure" $1 "pdbId:a protein databank identifier"
usage turtle
... now shows the updated information in the Log:
turtle pdbId
— open a PDB structure
pdbId: a protein databank identifier