Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

postgresql - customize pager in psql

When I use psql, the command line tool of PostgreSQL, in interactive mode, it lists data as paginated output.

However, because I use psql in a terminal application which can handle long outputs itself, I rather would like to get the whole output without the paginating with the annoying --more-- line.

Is there any way to customise the paging behavior in psql? I tried to set LESS in the surrounding shell environment to cat, but this din't help.

Any suggestions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the fine psql manual:

pset option [ value ]
[...]
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

So you can say this from the psql prompt:

psql> pset pager off

to turn the pager off. If you want this to always apply, you can add pset pager off to your ~/.psqlrc file.

You can also use ? from the psql prompt to get a quick summary of the special commands at your disposal.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...