Turn off pager for psql's interactive output

Solution 1:

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.

Solution 2:

Try switcher:

database_name=# \pset pager
Pager is used for long output.
database_name=# \pset pager
Pager usage is off.

Solution 3:

To turn off the pager when using psql in the shell :

psql -P pager=off ...

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.

export PAGER=
psql ...

Finally, a workaround that may be easier to remember: pipe the output through cat, which will disable the default pager

psql ... | cat

Solution 4:

Switch the pager off with

\pset pager off

Solution 5:

add below code in ~/.psqlrc to retain the behaviour

\pset pager off

Tags:

Psql