.psqlrc / psqlrc
~/.psqlrc is the default user configuration file for
psql. On UNIX/UNIX-like systems, this file will be in the user's home directory. On Windows, the user's configuration file is named %APPDATA%\postgresql\psqlrc.conf.
Additionally, a system-wide
psqlrc file may be present; this will usually be in the location specified by the
--sysconfdir and defaults to
/usr/local/pgsql/etc), however many distribution packages will place it in the system's standard configuration directory (e.g.
Both the system-wide psqlrc file and the user's ~/.psqlrc file can be made psql-version-specific by appending a dash and the PostgreSQL major or minor release number, for example ~/.psqlrc-11 or ~/.psqlrc-11.4. The most specific version-matching file will be read in preference to a non-version-specific file.
The following settings provide additional control over how psql processes configuration files:
- -X or --no-psqlrc
- These command-line options force psql not to read any configuration files (both the user's ~/.psqlrc file and the system-wide psqlrc file)
- -c command or --command command
- The psqlrc and ~/.psqlrc files will be ignored if either of these command line options are used
- PSQLRC environment variable:
- setting this variable will cause psql to look for the .psqlrc file in the specified location.