On Tue, Oct 18, 2016 at 12:26 PM, Jonathan Jacobson <jon...@gmail.com>
> The .psql_history file is naturally used by different DB connections
> (distinguished by a different combination of host + port + database + user).
> At least in my multi-database working environment, this leads sometimes to
> frustration because there are commands that cannot or should not be used by
> different connections.
> To solve this, psql could keep a separate command history file for each
> I will be happy to make this my first contribution to PostgreSQL's code.
> What do you say?
That's settable with HISTFILE
\set HISTFILE ~/.psql_history- :DBNAME
There's also :PORT and a few other vars.
(example borrowed from