Avoid output disappearing in psql I open psql and write:

mydb=&gt; \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.
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