We switched from PostgreSQL 8.3 to 9.0. Perhaps it's a new feature or perhaps just a configuration change, but now when output from commands (like, \d tablename
) exceeds visible vertical space, psql seem to pipe the output through something similar to less
. I could not find a way to turn this behaviour off. Any advice? Thanks.
P.S. I'm scrolling the buffer using PuTTY's Shift+PgUp/PgDn
so I don't need psql's paging. Plus, when I press q
in the psql's paging, its output disappears from the screen entirely (just like after running less
in bash), which is wrong from the general use-cases point of view.
TL;DR:
\pset pager 0
From the \pset section of the psql manual:
pager
Controls use of a pager program for query and psql help output. If the environment variable PAGER is set, the output is piped to the specified program. Otherwise a platform-dependent default (such as more) is used.
When the pager option is off, the pager program is not used. When the pager option is on, the pager is used when appropriate, i.e., when the output is to a terminal and will not fit on the screen. The pager option can also be set to always, which causes the pager to be used for all terminal output regardless of whether it fits on the screen. \pset pager without a value toggles pager use on and off.
Try switcher:
To turn off the pager when using
psql
in the shell :You could also export an empty
PAGER
environment variable, so you don't need to add the option to every statement. It will stay set until you close your current shell.Finally, a workaround that may be easier to remember: pipe the output through
cat
, which will disable the default pagerSwitch the pager off with
add below code in ~/.psqlrc to retain the behaviour
\pset pager off
Best way in summary is to set an environment variable for the pager, e.g.
PAGER='less -X' psql
or to set it once
export PAGER='less -X'
then run
psql