Customize your psql terminal

Here’s the contents of my ~/.psqlrc file:

-- Report time used for each query.

-- Set a cute border around query results.
\pset border 2

-- Set pager to less, rather than more.
\setenv PAGER /usr/bin/less

-- Monkey up the prompt.

-- This one shows user@host:database
-- \set PROMPT1 '%n@%m:%/%# '

-- Same thing, but with pretty colors, across several lines.
\set PROMPT1 '\n%[%033[0;36;29m%]%n@%m:%/%[%033[0m%]\n%# '

Now I get a psql prompt that looks like this:

# select * from current_timestamp;
| now |
| 2012-10-23 12:22:38.263557-04 |
(1 row)

Time: 1.907 ms

Published by


My name is Matt Wilson. I make websites for Kiwee to pay the bills. I live in Cleveland Heights, Ohio, with my wife and son.