Skip to content

Commit aa00af3

Browse files
committed
Improve FILES section of psql reference page.
Primarily, explain where to find the system-wide psqlrc file, per recent gripe from John Sutton. Do some general wordsmithing and improve the markup, too. Also adjust psqlrc.sample so its comments about file location are somewhat trustworthy. (Not sure why we bother with this file when it's empty, but whatever.) Back-patch to 9.2 where the startup file naming scheme was last changed.
1 parent ad2e041 commit aa00af3

File tree

2 files changed

+41
-29
lines changed

2 files changed

+41
-29
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,55 +3420,66 @@ PSQL_EDITOR_LINENUMBER_ARG='--line '
34203420
<refsect1>
34213421
<title>Files</title>
34223422

3423-
<itemizedlist>
3423+
<variablelist>
3424+
<varlistentry>
3425+
<term><filename>psqlrc</filename> and <filename>~/.psqlrc</filename></term>
34243426
<listitem>
34253427
<para>
3426-
Unless it is passed an <option>-X</option>
3427-
or <option>-c</option> option,
3428-
<application>psql</application> attempts to
3429-
read and execute commands from the system-wide
3430-
<filename>psqlrc</filename> file and the user's
3431-
<filename>~/.psqlrc</filename> file before starting up.
3432-
(On Windows, the user's startup file is named
3433-
<filename>%APPDATA%\postgresql\psqlrc.conf</filename>.)
3434-
See <filename><replaceable>PREFIX</>/share/psqlrc.sample</>
3435-
for information on setting up the system-wide file. It could be used
3436-
to set up the client or the server to taste (using the <command>\set
3437-
</command> and <command>SET</command> commands).
3428+
Unless it is passed an <option>-X</option> or <option>-c</option> option,
3429+
<application>psql</application> attempts to read and execute commands
3430+
from the system-wide startup file (<filename>psqlrc</filename>) and then
3431+
the user's personal startup file (<filename>~/.psqlrc</filename>), after
3432+
connecting to the database but before accepting normal commands.
3433+
These files can be used to set up the client and/or the server to taste,
3434+
typically with <command>\set</command> and <command>SET</command>
3435+
commands.
34383436
</para>
34393437
<para>
3440-
The location of the user's <filename>~/.psqlrc</filename> file can
3441-
also be set explicitly via the <envar>PSQLRC</envar> environment
3442-
setting.
3438+
The system-wide startup file is named <filename>psqlrc</filename> and is
3439+
sought in the installation's <quote>system configuration</> directory,
3440+
which is most reliably identified by running <literal>pg_config
3441+
--sysconfdir</>. By default this directory will be <filename>../etc/</>
3442+
relative to the directory containing
3443+
the <productname>PostgreSQL</productname> executables. The name of this
3444+
directory can be set explicitly via the <envar>PGSYSCONFDIR</envar>
3445+
environment variable.
3446+
</para>
3447+
<para>
3448+
The user's personal startup file is named <filename>.psqlrc</filename>
3449+
and is sought in the invoking user's home directory. On Windows, which
3450+
lacks such a concept, the personal startup file is named
3451+
<filename>%APPDATA%\postgresql\psqlrc.conf</filename>.
3452+
The location of the user's startup file can be set explicitly via
3453+
the <envar>PSQLRC</envar> environment variable.
34433454
</para>
3444-
</listitem>
3445-
3446-
<listitem>
34473455
<para>
3448-
Both the system-wide <filename>psqlrc</filename> file and the user's
3449-
<filename>~/.psqlrc</filename> file can be made <application>psql</application>-version-specific
3456+
Both the system-wide startup file and the user's personal startup file
3457+
can be made <application>psql</application>-version-specific
34503458
by appending a dash and the <productname>PostgreSQL</productname>
3451-
major or minor <application>psql</application> release number,
3459+
major or minor release number to the file name,
34523460
for example <filename>~/.psqlrc-9.2</filename> or
34533461
<filename>~/.psqlrc-9.2.5</filename>. The most specific
34543462
version-matching file will be read in preference to a
34553463
non-version-specific file.
34563464
</para>
34573465
</listitem>
3466+
</varlistentry>
34583467

3468+
<varlistentry>
3469+
<term><filename>.psql_history</filename></term>
34593470
<listitem>
34603471
<para>
34613472
The command-line history is stored in the file
34623473
<filename>~/.psql_history</filename>, or
34633474
<filename>%APPDATA%\postgresql\psql_history</filename> on Windows.
34643475
</para>
34653476
<para>
3466-
The location of the history file can
3467-
also be set explicitly via the <envar>PSQL_HISTORY</envar> environment
3468-
setting.
3477+
The location of the history file can be set explicitly via
3478+
the <envar>PSQL_HISTORY</envar> environment variable.
34693479
</para>
34703480
</listitem>
3471-
</itemizedlist>
3481+
</varlistentry>
3482+
</variablelist>
34723483
</refsect1>
34733484

34743485

src/bin/psql/psqlrc.sample

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--
2-
-- psql configuration file
2+
-- system-wide psql configuration file
33
--
44
-- This file is read before the .psqlrc file in the user's home directory.
55
--
6-
-- Copy this to your sysconf directory (typically /usr/local/pgsql/etc) and
7-
-- rename it psqlrc.
6+
-- Copy this to your installation's sysconf directory and rename it psqlrc.
7+
-- The sysconf directory can be identified via "pg_config --sysconfdir".
8+
--

0 commit comments

Comments
 (0)