|Purpose:||Create new command names that execute one or more commands or redefine default options for existing commands; assign commands to keystrokes; load or display the list of defined alias names|
ALIAS [/= /GL /LL /P] [wildname]
ALIAS [/= /G /GL /LL /O] [/R [/Z] file...] | name[=]value
|/=||Call the ALIAS command dialog|
|file||One or more input files to read alias definitions from|
|wildname||Name of alias whose definition is to be displayed (may contain * and ? wildcards)|
|name||Name for an alias, or for the key to execute the alias|
|value||Text to be substituted for the alias name or key|
The ALIAS command lets you create new command names or redefine internal commands. It also lets you assign one or more commands to a single keystroke. An alias is often used to execute a complex series of commands with a few keystrokes or to create "in memory batch files" that run much faster than disk-based batch files.
For example, to create a single-letter command d to display a wide directory, instead of using DIR /W, you could use the command:
alias d = dir /w
Now when you type a single d as a command, it will be translated into a DIR /W command.
If an ALIAS command specifies a value, and there was an alias already assigned to name, the old alias value is discarded.
If you define aliases for commonly used application programs, you can often remove the directories they're stored in from the PATH. For example, if you use Microsoft Word and had the C:\WINWORD directory in your path, you could define the following alias:
alias ww = c:\winword\winword.exe
With this alias defined, you can probably remove C:\WINWORD from your path. Word will now load more quickly than it would if TCC had to search the PATH for it. In addition, PATH can be shorter, which will speed up searches for other programs.
If you apply this technique for each application program, you can often reduce your PATH to just two or three directories containing utility programs, and significantly reduce the time it takes to load most software on your system. Before removing a directory from the PATH, you will need to define aliases for all the executable programs you commonly use which are stored in that directory.
TCC also supports Directory Aliases, a shorthand way of specifying pathnames.
An Alias name can be contained in a variable. When TCC does variable expansion on a command line, it will check if the expansion changed the first argument on the line, and if so TCC will check to see if the new argument is an alias. For example:
Alias %AliasName=Echo Hello
:: Will output: Echo Hello
:: Will output: Hello
Aliases are stored in memory, and are not saved automatically when you turn off your computer or end your current TCC session. See below for information on saving and reloading your aliases.
If you want to see a list of all currently defined aliases, type:
You can view the definition of a single alias. For example, if you want to see the definition of the alias LIST, you can type:
You can also view the definitions for all aliases matching a specific pattern by specifying a single parameter containing wildcards (* or ?). For example:
will display all aliases containing the string win.
You can use the /P option to control display scrolling when displaying aliases.
An alias can represent more than one command. For example:
alias letters = `cd \letters & tedit`
This alias creates a new command called LETTERS. The command first uses CD to change to a subdirectory called \LETTERS of the directory current at the time of its execution, and then runs a program called TEDIT.
When an alias contains multiple commands, the commands are executed one after the other. However, if any of the commands runs an external Windows application, you must be sure the alias will wait for the application to finish before continuing with the other commands. This behavior is controlled by the Wait for completion setting in the configuration dialogs.
When you use the alias command at the command prompt or in a batch file, you must use back quotes ` around the alias definition if it contains multiple commands, or parameters (discussed below), or environment variables, or variable functions, or redirection, or piping. If you do not use back quotes, parameters, variables and functions are evaluated, and redirection or piping performed during the alias definition, and only the first command becomes part of the alias, the remaining ones are performed immediately. The back quotes prevent this premature expansion. You may use back quotes around other definitions, but they are not required. You do not need back quotes when your aliases are loaded from an ALIAS /R file; see below for details. The examples above and below include back quotes only when they are required.
Aliases may invoke internal commands, external commands, or other aliases. However, an alias may not invoke itself, except in special cases where an IF or IFF command is used to prevent an infinite loop. The two aliases below demonstrate alias nesting (one alias invoking another). The first line defines an alias which runs in the current directory, and executes Word located in the E:\WINWORD\. The second alias changes directories with the PUSHD command, runs the WP alias, and then returns to the original directory with the POPD command:
alias wp = e:\winword\winword.exe
alias w = `pushd c:\wp & wp & popd`
The second alias above could have included the full path and name of WINWORD.EXE instead of calling the WP alias. However, writing two aliases makes the second one easier to read and understand, and makes the first alias available for independent use. If you rename the WINWORD.EXE program or move it to a new directory, only the first alias needs to be changed.
If you put an asterisk * immediately before a command in the value of an alias definition (the part after the equal sign), it tells TCC not to attempt to interpret that command as another (nested) alias. An asterisk used this way must be preceded by a space or the command separator and followed immediately by an internal or external command name.
By using an asterisk, you can redefine the default options for any internal or external command. For example, suppose that you always want to use the DIR command with the /2 (two column) and /P (pause at the end of each page) options:
alias dir = *dir /2/p
If you didn't include the asterisk, the second DIR on the line would be the name of the alias itself, and TCC would repeatedly re invoke the DIR alias, rather than running the DIR command. This would cause an "Alias loop" or "Command line too long" error. The asterisk forces interpretation of the second DIR as a command, not an alias.
An asterisk also helps you keep the names of internal commands from conflicting with the names of external programs. For example, suppose you have a program called DESCRIBE.EXE. Normally, the internal DESCRIBE command will run anytime you type DESCRIBE. But two simple aliases will give you access to both the DESCRIBE.EXE program and the DESCRIBE command:
alias describe = c:\winutil\describe.exe
alias filedesc = *describe
The first line above defines describe as an alias for the DESCRIBE.EXE program. If you stopped there, the external program would run every time you typed DESCRIBE and you would not have easy access to the internal DESCRIBE command. The second line defines FILEDESC as a new name for the internal DESCRIBE command. The asterisk is needed in the second command to indicate that the following word means the internal command DESCRIBE, not the describe alias which runs your external program.
Another way to understand the asterisk is to remember that a command is always checked for an alias first, then for an internal or external command, or a batch file. The asterisk at the beginning of a command name simply skips over the usual check for aliases when processing that command, and allows TCC to go straight to checking for an internal command, external command, or batch file.
You can prevent alias expansion by using an asterisk before a command that you enter at the command line or in a batch file. This can be useful when you want to be sure you are running the original command and not an alias with the same name, or temporarily defeat the purpose of an alias which changes the meaning or behavior of a command. For example, above we defined an alias for DIR which made directories display in 2-column paged mode by default. If you wanted to see a directory display in the normal single-column, non-paged mode, you could enter the command *DIR and the alias would be ignored for that command.
You can disable aliases temporarily with the SETDOS /X command.
You can also use an asterisk in the name of an alias. When you do, the characters following the asterisk are optional when you invoke the alias command. (Use of an asterisk in the alias name is unrelated to the use of an asterisk in the alias value discussed above.) For example, with this alias:
alias wher*eis = dir /s /p
The new command, WHEREIS, can be invoked as WHER, WHERE, WHEREI, or WHEREIS. Now if you type:
The WHEREIS alias will be expanded to the command:
dir /s /p myfile.txt
Assignment: To assign an insert-only alias to a keystroke, use the key name on the left side of the equal sign, preceded by one at sign @, and the value of the alias on the right side of the equal sign:
Operation: When you press the key to which you assigned an insert-only alias, TCC displays and inserts the alias value in the current command line, at the current cursor position. If your command line editing mode is overwrite, and the cursor is not at the end of the line, the alias value will overwrite part of the command line. You can continue to edit the command line, e.g., adding other parameters to the command. You must press Enter to execute the command.
To assign the command DIR /W to the F4 key, type:
alias @F4 = dir /w
To use it, press F4 at the command prompt, and DIR /W will be placed on the command line for you. You can type additional parameters if you wish, and press Enter to execute the command. With the example alias, you can define the files that you want to display after pressing F4 and before pressing Enter to execute the command.
You can also define a keystroke alias to insert a frequently used string into the middle of a command, e.g.,
alias @shift-F4 =%@expand[
which specific example can assist in processing wildcards for a program without such a feature.
Assignment: To assign an autoexecute alias to a keystroke, use the key name on the left side of the equal sign, preceded by two at signs @@, and the value of the alias on the right side of the equal sign:
Operation: When you press the key to which you assigned an autoexecute alias, TCC inserts the alias value in the current command line, at the current cursor position. If your command line editing mode is overwrite, and the cursor is not at the end of the line, the alias value will overwrite part of the command line. After the insertion/overwrite the command line is automatically executed.
Example: This command will assign an alias to the F11 key that uses the CDD command to take you back to the previous default directory:
alias @@f11 = cdd -
Special Considerations for Keystroke Aliases
When you define keystroke aliases, the assignments will only be in effect at the command line, not inside application programs or batch files.
To insure that a keystroke alias, esp. an autoexecute one, is on the command line by itself, use the character defined by the EraseLine key directive option (by default, the Esc key, represented as ^e) as the first character of the alias value.
To force a visible indication that an autoexecute keystroke alias was used, include a descriptive ECHO command in the alias value.
Be careful if you assign aliases to keys that are already used at the command line (e.g., F1 for HELP). The keystroke alias definitions take precedence, so they will disable the matching command line editing key.
The value of an alias, including a keystroke alias, may contain only characters. It cannot contain representations of keys such as F1 .. F12, Home, etc.
See Keys and Key Names for a complete listing of key names and a description of the key name format.
Directory Aliases are a shorthand way of specifying pathnames. For example, if you define an alias:
alias pf:=c:\program files
You can then reference the files in c:\program files\jpsoft by entering pf:\jpsoft. Directory aliases work in places that accept filenames and directory names (internal command arguments or the first argument in a command line), including filename completion. You cannot use them in arguments to external applications, as TCC has no way of knowing what is a valid argument for external applications.
Directory alias names can be either two or more alphanumeric characters followed by a colon, or a single digit followed by a colon. You cannot abbreviate directory aliases.
Directory aliases support environment variable expansion.
You can save your aliases to a file:
alias > alias.lst
You can then reload all the alias definitions in the file the next time you start up with the command:
alias /r alias.lst
This is much faster than defining each alias individually in a batch file. If you keep your alias definitions in a separate file which you load when TCC starts, you can edit them with a text editor, reload the edited file with ALIAS /R, and know that the same alias list will be loaded the next time you start TCC.
When you define aliases in a file that will be read with the ALIAS /R command, do not use back quotes around the value, even if back quotes would normally be required when defining the same alias at the command line or in a batch file.
To remove an alias, use the UNALIAS command.
Aliases can use command line parameters or parameters like those in batch files. The command line parameters are numbered from %0 to %511. (%0 contains the alias name.) You can use double quotes to pass spaces, tabs, commas, and other special characters in an alias parameter; see Parameter Quoting for details. (Alias examples in this section assume the TCC default of ParameterChar=$.)
Parameters that are referred to in an alias, but which are missing on the command line, appear as empty strings inside the alias. For example, if you only put two parameters on the command line, any reference in the alias to %3 or any higher-numbered parameter will be interpreted as an empty string.
The parameter %n$ has a special meaning. TCC interprets it to mean "the entire command line, from parameter n to the end." If n is not specified, it has a default value of 1, so %$ means "the entire command line after the alias name."
The parameter %-n$ means "the command line from parameter 1 to n - 1".
The special parameter %# contains the number of command line parameters.
For example, the following alias will change directories, perform a command, and return to the original directory:
alias in `pushd %1 & %2$ & popd`
When this alias is invoked as:
in c:\comm mycomm /zmodem /56K
The first parameter, %1, has the value c:\comm. %2 is mycomm, %3 is /zmodem, and %4 is /56K. The command line expands into these three separate commands:
mycomm /zmodem /56K
alias set = `iff %# == 0 then & *set /p & else & *set %$ & endiff`
This modifies the SET command so that if SET is entered with no parameters, it is replaced by SET /P (pause after displaying each page), but if SET is followed by a parameter, it behaves normally. Note the use of asterisks (*set) to prevent alias loops.
If an alias uses parameters, command line parameters will be deleted up to and including the highest referenced parameter. For example, if an alias refers only to %1 and %4, then the first and fourth parameters will be used, the second and third parameters will be discarded, and any additional parameters beyond the fourth will be appended to the expanded command (after the value portion of the alias). If an alias uses no parameters, all of the command line parameters will be appended to the expanded command. A convenient way to prevent unwanted command line parameters from being appended is to add a reference to %511 within the alias.
Aliases also have full access to all variables in the environment, internal variables, and variable functions. For example, you can create a simple command line calculator this way:
alias calc = `echo The answer is: %@eval[%$]`
Now, if you enter:
calc 5 * 6
The alias will display:
The answer is: 30
You can expand an alias on the command line and view or edit the results by pressing Ctrl-W after typing the alias name, but before the command is executed. This replaces the alias with its contents, and substitutes values for each alias parameter, just as if you had pressed the Enter key. However, the command is not executed; it is simply redisplayed on the command line for additional editing.
Ctrl-W is especially useful when you are developing and debugging a complex alias, or if you want to make sure that an alias that you may have forgotten won't change the effect of your command.
Aliases can be stored in local and/or global lists. The selection is made during TCC startup, using the /L or /LA START or startup options, or by the Local Aliases and Global Aliases configuration options, or interactively with the ALIAS /G, /GL, /L, and /LL options. The global alias list is limited to 256 K characters; the local alias list is limited only by memory size.
With a local alias list, any changes made to the aliases will only affect the current copy of TCC. They will not be visible in other shells or other sessions.
With a global alias list, all copies of TCC, which are started with global alias list will share the same alias list, and any changes made to the aliases in one copy will affect all other copies. This is the default for TCC.
If you don't specify /GL or /LL, TCC will first look for aliases in the local list. If there is no local list or the alias is not found, TCC will search the global list (if it exists).
There is no fixed rule for determining whether to use local or global alias lists. Depending on your work style, you may find it most convenient to use one type, or a mixture of types in different sessions or shells. We recommend that you start with the default approach, then modify it if you find a situation where the default is not convenient.
If you select a global alias list for TCC you can share the aliases among all running copies of TCC. When you close all TCC sessions, the memory for the global alias list is released, and a new, empty alias list is created the next time you start TCC.
If you want the alias list to be retained in memory even when no TCC session is running, you need to execute the SHRALIAS command, which performs this service for the global alias list, the global user-defined functions list, the global command history list, and the global directory history list. You may find it convenient to execute SHRALIAS from your TCSTART file.
SHRALIAS retains the global alias list in memory, but cannot preserve it when Windows itself is shut down. To save your aliases when restarting Windows, you must store them in a file and reload them after the system restarts. For details on how to do so, see Saving and Reloading Your Aliases above.
When at the command prompt (i.e., not executing a batch file), TCC will look for (and execute them if found) the following aliases:
PRE_INPUT - executed immediately before accepting input for a new command line.
PRE_EXEC - executed immediately after a command line is entered (before any expansion or redirection).
POST_EXEC - executed immediately after returning from a command and before displaying the prompt.
None of these aliases will be passed any arguments.
If the alias does not exist, TCC will search the plugins for PRE_INPUT / PRE_EXEC / POST_EXEC functions and execute them if found.
If you create an alias with the name UNKNOWN_CMD, it will be executed any time TCC would normally issue the "Unknown command" error message. This allows you to define your own handler for unknown commands. When the UNKNOWN_CMD alias is executed, the command line which generated the error is passed to the alias for possible processing. For example, to just display the command that caused the error:
alias unknown_cmd `echo Error in command "%$"`
If the UNKNOWN_CMD alias contains an unknown command, it will call itself repeatedly. If this occurs, TCC will loop up to 10 times, then display the UNKNOWN_CMD loop error.
If an UNKNOWN_CMD alias does not exist, TCC will search the plugins for an UNKNOWN_CMD command and execute it if found.
When you define an alias in the command line (i.e., without using the /R option), variables and functions not protected by back quotes or doubled % signs are immediately evaluated, and the result becomes part of the alias value.
Syntax errors in an alias are not detected until the alias is executed.
|/=||Display the ALIAS command dialog to help you set the command line options. The /= option can be anywhere on the line; additional options will set the appropriate fields in the command dialog.|
|/G||Switch from a local to a global alias list. If you already have a global alias list (for example, in another TCC instance or in SHRALIAS), ALIAS will not do the conversion. The /G must be the only argument.|
|/GL||Read from and write to the global alias list. If you have both local and global alias lists defined and do not specify /GL, ALIAS will default to using the local list.|
|/L||Switch from a global to a local alias list. If you already have a local alias list, ALIAS will not do the conversion. The /L must be the only argument.|
|/P||This option is only effective when ALIAS is used to display existing definitions. It pauses the display after each page and waits for a keystroke before continuing (see Page and File Prompts).|
|/R||This option loads an alias list from a file. The format of the file is the same as that of the ALIAS display:|
where name is the name of the alias and value is its value. You can use an equal sign = or space to separate name and value. Do not use back quotes around the value with /R. Variables and functions referenced in the definitions remain in the definitions, to be evaluated each time the alias is executed. You can add comments to the file by starting each comment line with a colon :. You can load multiple files with one ALIAS /R command by placing the names on the command line, separated by spaces:
alias /r alias1.lst alias2.lst
ALIAS /R definitions can span multiple lines in the file if each line of the definition, except the last, is terminated with an escape character.
ALIAS /R will read from stdin if no filename is specified and input is redirected:
alias /r <
|/Z||Overwrite the existing alias list with the contents of the specified file (must be used with /R). ALIAS /R /Z is 20x faster than an ALIAS /R, because it doesn't have to check for existing aliases and append new aliases to the end of the list. Do not use single back quotes around your alias arguments with /Z.|