Skip to content

Instantly share code, notes, and snippets.

@bidulock
Last active December 11, 2015 02:29
Show Gist options
  • Save bidulock/4530751 to your computer and use it in GitHub Desktop.
Save bidulock/4530751 to your computer and use it in GitHub Desktop.
my .psqlrc file
-- Include the hostname in the prompt, and add a * when in a transaction
-- The default PROMPT2 doesn't make it obvious enough nothing has been sent to the server yet
\set PROMPT1 '%M:%/%R%x%# '
\set PROMPT2 '> '
-- Always be in a transaction. It's safer this way
\set AUTOCOMMIT off
-- Turn the pager on always. This is best used with "export PAGER=less -S -F -X" added to your .bashrc
\pset pager always
-- History files stored in the .psql_history directory in the form <hostname>-<dbname>
\set HISTFILE ~/.psql_history/:HOST - :DBNAME
\set HISTSIZE 2000
-- Always display timing information.
\timing
\encoding unicode
@mfrank01
Copy link

mfrank01 commented Mar 7, 2014

If you add
\i .psql:HOST
to this file, you can have it load different configuration files depending on the host that you are connecting to.

In my production .psqlPRODUCTION file, I have inserted the line
\set PROMPT1 '%[%033[91m%]%M:%/%R%x%#%[%033[0m%] '
to turn the prompt red.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment