alias

Function

The alias command creates an alias for a command.

The undo alias command deletes an alias.

By default, no alias is created.

Format

alias alias-string [ parameter { parameter } &<1-32> ] command command

undo alias alias-string

Parameters

Parameter Description Value
alias-string

Specifies an alias string.

The value is a string of 1 to 63 case-insensitive characters, supporting letters, digits, and hyphens (-). It must start with a letter and cannot contain spaces between characters.

parameter parameter

Specifies a parameter for an alias.

The value is a string of 2 to 63 case-insensitive characters, supporting letters, digits, and hyphens (-). It must start with the $ sign.

command command

Specifies a command for which an alias is to be created.

The value is a string of 1 to 511 characters. If a space exists in the command, the character string of command must be enclosed in double quotation marks ("). An alias can be configured for each command supported by the device.

Views

Command alias view

Default Level

3: Management level

Task Name and Operations

Task Name Operations
cli write

Usage Guidelines

Usage Scenario

The alias command can be used in the following scenarios:

  • Configure an easy-to-remember string of characters as the alias for a command. Then, you can just enter the alias string when you need to run the command. For example, define the alias for display as show. You can enter the alias show to substitute display.
  • Change the order of parameters. For example, after you configure the alias showif parameter $ifnum $iftype command "display interface $iftype $ifnum" command, you can enter showif 1 Eth-Trunk to substitute display interface Eth-Trunk 1.

Precautions

  • A command can still be used after an alias is configured for it.
  • The character string of parameter command must reference all the parameters defined in parameter in sequence, and each parameter can be referenced only once.
  • When the character string of parameter command starts referencing the parameters defined in parameter, only parameters beginning with the $ sign rather than any command keyword can be included. For example, command configuration like alias showif parameter $ifnum $iftype command "display interface $iftype iftype $ifnum verbose" is incorrect.
  • If the alias definitions include loop nesting or the nesting level is more than 16 layers, the alias is invalid and cannot substitute a command.
  • The alias configured by the alias command can take effect only when the command alias function is enabled using the terminal command alias command. By default, the command alias function is enabled.

Example

# Create an alias for a command.
<HUAWEI> system-view
[~HUAWEI] command alias
[~HUAWEI-cmdalias] alias show command display
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >