Defining aliases

Command aliases are defined in an alias file. To define one or more aliases, you do the following:

  1. Create a file named .p4aliases in your home directory (p4aliases.txt in Windows).

    (The file is stored in your $HOME directory on Unix and Mac systems, and in your $USERPROFILE directory on Windows.)

    If you do not put the alias file in the home directory, you must define the P4ALIASES environment variable to specify the location of the alias file.

  2. Add one or more alias definitions to the alias file.

    The following topics in this section explain the syntax of alias definitions and provides examples of alias definitions.

    Tip

    The alias file can:

    • contain blank lines, but they will be ignored
    • contain comments lines. A comment line begins with # as the first non-blank character.

    • be edited as often as you like to add, modify, or delete definitions
  3. Preview the effect of the aliases you have defined by running a command like the following for a given command alias:

    $ p4 --aliases=dry-run myalias

    The output to the alias command will show you the command or commands that would be run without actually running the command. For more information, see Previewing alias substitutions.

  4. Run the command alias to execute the command or commands associated with the alias.

    The server processes command aliases in the order they have been defined, going through each one until it finds one that modifies the current command. It then restarts from the beginning, rechecking each alias. This means that a given command might be transformed more than once before it is run, depending on the aliases that use the command.

Use the p4 aliases command to get a listing of all currently defined aliases.