\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?
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
This thread seems relevant (paraphrasing):
The pager is probably not set, see here for more info:
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.