Know your HISTFILE
Today I learned that psql has a cool feature called the HISTFILE. It's a record of your commands in the REPL, named ~/.psql_history
by default.
Building off Josh's post yesterday about ~/.psqlrc
settings, add this there to get a unique log for each database:
\set HISTFILE ~/.psql_history-:DBNAME
Here's the tail of my TIL log:
$ tail ~./psql_history-hr-til_development
select * from developers limit 1;
select * from developers limit 2;
select * from developers limit 3;
This is just a text file; it can be edited. You could add a complex command, or meaningful reminder to yourself, and it will be available in psql when you traverse your history (↑ or CTRL-P).
Tweet