Edit specs and workspace alias files

Consider the advanced uses of command aliases.

Editing specifications

The p4subst special operator:

  • Allows you to edit specs.

  • Has an effect that is similar to the following command in a shell pipeline:
    | sed 's/regular_expression/literal/g'

You can use the p4subst special operator in an alias as follows:

Copy
something > $(output) &&
p4subst "regular expression" "literal replacement" < $(output) > $(result) &&
something else < $(result)

For example, consider the string substitution in the alias:

Copy
newChange $(desc) = change -o > $(chg) &&
                   p4subst "$(LT)enter.*$(GT)" $(desc) < $(chg) > $(chg2) &&
                   change -i < $(chg2)

The alias replaces the default change description with the argument provided to p4 newChange description.

Creating alias files for each workspace

You can have a P4ALIASES file that is specific to this client workspace and that is found no matter where you are in the client workspace

To create an alias file for each workspace, add the following line to your P4CONFIG file:
P4ALIASES=$configdir/p4aliases.txt