P4COLORS

Controls the terminal output colors used by P4 Server client commands. Each rule maps a message field or output level to an ANSI SGR color code.

Usage notes

Used by client? Used by server? Command-line alternative Can be set in P4CONFIG file?

Yes

No

N/A

Yes

Value if not explicitly set

Operating system Value

All

None. Output uses the terminal default colors.

Syntax

The value of P4COLORS is a colon-separated list of color rules:

P4COLORS=rule[:rule...]

Each rule has the form:

[(field=value)]selector=style[;foreground[;background]]

where:

  • selector is either an output level (@info, @warning, or @error) that matches an entire output line at that level, or the name of a tagged field (for example, depotFile) that colors only that field's value within the line. Run p4 -e command to see the tagged fields available for a command.

  • style, foreground, and background are ANSI SGR codes. See SGR codes reference.

  • The optional (field=value) prefix is a selector that restricts the rule to output lines where the named tagged field equals the given value.

Examples

Leave info output at the default color, display warnings in yellow, and errors in red:

P4COLORS=@info=0:@warning=1;33;40:@error=1;31;40

Display any info line where the user field is jsmith in bold purple:

P4COLORS=(user=jsmith)@info=1;35;40

Display the depotFile field in bold cyan wherever it appears, leaving the rest of the line uncolored:

P4COLORS=depotFile=1;36

Notes

To discover the tagged fields that a command emits, run it with the -e global option. For example:

p4 -e sync

SGR codes reference

The following tables list the ANSI SGR codes accepted by P4COLORS.

Style codes

Code Effect

0

Default

1

Bold

4

Underline

7

Invert colors

Foreground color codes

Code Color

30

Black

31

Red

32

Green

33

Yellow

34

Blue

35

Magenta (purple)

36

Cyan

37

White

Background color codes

Code Color

40

Black

41

Red

42

Green

43

Yellow

44

Blue

45

Magenta (purple)

46

Cyan

47

White