patternsqlMinor
Avoid output disappearing in psql
Viewed 0 times
psqldisappearingoutputavoid
Problem
I open
and this list of tables is shown:
The I have to press
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.
psql and write:mydb=> \dtand 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.
Solution
Assuming your pager is
From
-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
\setenv LESS -FX
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
Context
StackExchange Database Administrators Q#163561, answer score: 8
Revisions (0)
No revisions yet.