Amelio Vazquez-Reina
Amelio Vazquez-Reina

Reputation: 96264

psql: Init files?

In the psql documentation, I read information about variables (section advanced features), e.g. one of these variables is:

HISTSIZE
The number of commands to store in the command history. The default value is 500.

Is there a file in the home directory or somewhere else where I can configure these variables?

What syntax would I use in that file?

Upvotes: 2

Views: 3171

Answers (1)

mu is too short
mu is too short

Reputation: 434635

If you look at the Files section, you'll see this:

Files

  • Unless it is passed an -X or -c option, psql attempts to read and execute commands from the system-wide psqlrc file and the user's ~/.psqlrc file before starting up. (On Windows, the user's startup file is named %APPDATA%\postgresql\psqlrc.conf.) See PREFIX/share/psqlrc.sample for information on setting up the system-wide file. It could be used to set up the client or the server to taste (using the \set and SET commands).

    The location of the user's ~/.psqlrc file can also be set explicitly via the PSQLRC environment setting.

So like most Unix commands, there is an RC ("Run Commands") file that you can use for configuration, the name also matches the Unix conventions of ~/.cmdrc so you want ~/.psqlrc.

The format matches the \set commands you'd use within psql itself:

\set HISTSIZE 11

for example.

Upvotes: 5

Related Questions