Basic examples of command aliases

You can define aliases for simple commands.

Before you can define an alias, you must create an alias file. See Define a command alias.

Shorten a command

Shorten the command for getting the current P4 user:

me = set P4USER

Rename commands

Rename some commands to match those of another version control system:

checkout = sync
commit = submit
purge = clean
stash = shelve
stash-list = changes -s shelved

Run multiple commands

Use a single command to preview open files and check their sync status:

my-status = status && sync -n

Set different defaults

Modify the default actions of some commands:

annotate = annotate -u
grep = grep -i
changes = changes -u $(P4USER)

Run a multi-step process

Simplify a system administration process (shutting down the server, displaying active users, and viewing current database locks):

halt = admin stop
active-users = changes -m 3 &&
               monitor show &&
               lockstat

Use commands with arguments

Create a command that takes a changelist as its argument:

kill-shelf $(cl) = shelve -d -c $(cl) &&
                   change -d $(cl)

Change the order of arguments

Create a command for cloning files in a target directory as user bruges:

clone $(p4port) $(path) $(dir) = -d $(dir) -u bruges clone -p $(p4port) -f $(path)

This command could be used like so:

clone perforce:1666 //depot/main/p4...  ~/local-repos/main