Set PostgreSQL pager to less?

I'm trying to get my psql pager output to look nicer.

I've added the following to my ~/.bashrc

export PAGER='less -S'

And I've added these line to my ~/.psqlrc

\x auto
\pset pager on
\setenv PAGER less

Current output:

Current pager output

Desired output:

Desired pager output


Solution 1:

\setenv PAGER less in .psqlrc overwrites the environment variable with an undesirable different value (without the -S option).

Either remove it, or change it to \setenv PAGER 'less -S', or create a new environment variable LESS set to -S

Note that even when less is not called with the -S / --chop-long-lines option, hitting the right arrow key will scroll horizontally and temporarily display lines without wrapping them.