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:
-
selectoris 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. Runp4 -e commandto see the tagged fields available for a command. -
style,foreground, andbackgroundare 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 |
|---|---|
|
|
Default |
|
|
Bold |
|
|
Underline |
|
|
Invert colors |
Foreground color codes
| Code | Color |
|---|---|
|
|
Black |
|
|
Red |
|
|
Green |
|
|
Yellow |
|
|
Blue |
|
|
Magenta (purple) |
|
|
Cyan |
|
|
White |
Background color codes
| Code | Color |
|---|---|
|
|
Black |
|
|
Red |
|
|
Green |
|
|
Yellow |
|
|
Blue |
|
|
Magenta (purple) |
|
|
Cyan |
|
|
White |