2

When using psql, \d <table> or select * from XXXX, after I exit and go back to shell, the information is not there and I need it to do the next command all the time. This is very very annoying. Is there any way to tell psql to always display what I just queried and leave it on the screen?

4

If info is vanishing when you exit the pager, and you don't want it to, change your pager settings. You're probably using less as your pager by default. The simplest option is to disable pagination:

\pset pager off

so results stream out of the terminal directly. You will want to set a rather larger scroll-back buffer in your terminal program if you do this.

Alternately, look at setting the PAGER environment variable to something that won't restore the display on pager exit, e.g:

export PAGER="less -X"

You can also set a custom pager in your .psqlrc if you only want it to affect psql.

1
  • wow, the export PAGER="less -X" really really rocks!!! thanks! Jan 14 '14 at 16:50
1

This thread seems relevant (paraphrasing):

The pager is probably not set, see here for more info:

http://www.postgresql.org/docs/9.2/interactive/app-psql.html

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.

1
  • Actually, I suspect it's the opposite: They're complaining that the pager (probably less) is clearing the terminal when they exit the pager. Jan 14 '14 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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