I open psql and write:

mydb=> \dt

and this list of tables is shown:

                   List of relations
 Schema |            Name            | Type  |  Owner  
 public | auth_group                 | table | foouser

The I have to press Esc to return to the prompt, and the output disappears like it was a less session.

I want to keep the output around so that I can use the information in it to write queries, but googling does not find an option to do that.

  • It looks like if the terminal is big enough, the output is printed instead of being opened in this sort of less. However, this only solves the problem for outputs which are fewer than 30 lines or so. Feb 8, 2017 at 9:56

2 Answers 2


Assuming your pager is less, try LESS=-FX; export LESS in your shell environment.

From man less:

      -F or --quit-if-one-screen
              Causes less to automatically exit if the entire file can be dis‐
              played on the first screen.

      -X or --no-init
              Disables sending the termcap initialization and deinitialization
              strings to the terminal.  This is  sometimes  desirable  if  the
              deinitialization  string does something unnecessary, like clear‐
              ing the screen.

To have this only in psql, set it with a meta-command in .psqlrc:

\setenv LESS -FX

You can turn off the use of the pager through

\pset pager off

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.