Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e1ff780

Browse files
committed
Document color support
Add a documentation appendix that explains the PG_COLOR and PG_COLORS environment variables. Discussion: https://www.postgresql.org/message-id/flat/bbdcce43-bd2e-5599-641b-9b44b9e0add4@2ndquadrant.com
1 parent 9cedb16 commit e1ff780

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

doc/src/sgml/color.sgml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!-- doc/src/sgml/color.sgml -->
2+
3+
<appendix id="color">
4+
<title>Color Support</title>
5+
6+
<indexterm zone="color">
7+
<primary>color</primary>
8+
</indexterm>
9+
10+
<para>
11+
Most programs in the PostgreSQL package can produce colorized console
12+
output. This appendix describes how that is configured.
13+
</para>
14+
15+
<sect1 id="color-when">
16+
<title>When Color is Used</title>
17+
18+
<para>
19+
To use colorized output, set the environment variable
20+
<envar>PG_COLOR</envar><indexterm><primary>PG_COLOR</primary></indexterm>
21+
as follows:
22+
23+
<orderedlist>
24+
<listitem>
25+
<para>
26+
If the value is <literal>always</literal>, then color is used.
27+
</para>
28+
</listitem>
29+
30+
<listitem>
31+
<para>
32+
If the value is <literal>auto</literal> and the standard error stream
33+
is associated with a terminal device, then color is used.
34+
</para>
35+
</listitem>
36+
37+
<listitem>
38+
<para>
39+
Otherwise, color is not used.
40+
</para>
41+
</listitem>
42+
</orderedlist>
43+
</para>
44+
</sect1>
45+
46+
<sect1 id="color-which">
47+
<title>Configuring the Colors</title>
48+
49+
<para>
50+
The actual colors to be used are configured using the environment variable
51+
<envar>PG_COLORS</envar><indexterm><primary>PG_COLORS</primary></indexterm>
52+
(note plural). The value is a colon-separated list of
53+
<literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal>
54+
pairs. The keys specify what the color is to be used for. The values are
55+
SGR (Select Graphic Rendition) specifications, which are interpreted by the
56+
terminal.
57+
</para>
58+
59+
<para>
60+
The following keys are currently in use:
61+
<variablelist>
62+
<varlistentry>
63+
<term><literal>error</literal></term>
64+
<listitem>
65+
<para>used to highlight the text <quote>error</quote> in error messages</para>
66+
</listitem>
67+
</varlistentry>
68+
69+
<varlistentry>
70+
<term><literal>warning</literal></term>
71+
<listitem>
72+
<para>used to highlight the text <quote>warning</quote> in warning
73+
messages</para>
74+
</listitem>
75+
</varlistentry>
76+
77+
<varlistentry>
78+
<term><literal>locus</literal></term>
79+
<listitem>
80+
<para>used to highlight location information (e.g., program name and
81+
file name) in messages</para>
82+
</listitem>
83+
</varlistentry>
84+
</variablelist>
85+
</para>
86+
87+
<para>
88+
The default value is <literal>error=01;31:warning=01;35:locus=01</literal>
89+
(<literal>01;31</literal> = bold red, <literal>01;35</literal> = bold
90+
magenta, <literal>01</literal> = bold default color).
91+
</para>
92+
93+
<tip>
94+
<para>
95+
This color specification format is also used by other software packages
96+
such as <productname>GCC</productname>, <productname>GNU
97+
coreutils</productname>, and <productname>GNU grep</productname>.
98+
</para>
99+
</tip>
100+
</sect1>
101+
</appendix>

doc/src/sgml/filelist.sgml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170

171171
<!ENTITY limits SYSTEM "limits.sgml">
172172
<!ENTITY acronyms SYSTEM "acronyms.sgml">
173+
<!ENTITY color SYSTEM "color.sgml">
173174

174175
<!ENTITY features-supported SYSTEM "features-supported.sgml">
175176
<!ENTITY features-unsupported SYSTEM "features-unsupported.sgml">

doc/src/sgml/postgres.sgml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@
278278
&docguide;
279279
&limits;
280280
&acronyms;
281+
&color;
281282

282283
</part>
283284

0 commit comments

Comments
 (0)