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?

growse
  • 8,020
  • 13
  • 74
  • 115
Dean Hiller
  • 911
  • 4
  • 15
  • 35

2 Answers2

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.

Craig Ringer
  • 11,083
  • 9
  • 40
  • 61
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.

Milen A. Radev
  • 962
  • 5
  • 17
  • Actually, I suspect it's the opposite: They're complaining that the pager (probably `less`) is clearing the terminal when they exit *the pager*. – Craig Ringer Jan 14 '14 at 01:05