在psql中自定义传呼机 [英] customize pager in psql
问题描述
当我以交互模式使用PostgreSQL的命令行工具 psql
时,它将列出数据作为分页输出。
When I use psql
, the command line tool of PostgreSQL, in interactive mode, it lists data as paginated output.
但是,因为我在可以处理长输出的终端应用程序中使用了 psql
,所以我想得到整个输出而不用烦人的-more-
行进行分页。
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.
有什么方法可以自定义 psql
中的分页行为?我试图在周围的shell环境中将 LESS
设置为 cat
,但这无济于事。
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.
有什么建议吗?
推荐答案
来自精整 psql
手册:
\pset选项[值]
[...] < br>
pager
控制使用分页器
程序进行查询和psql帮助输出。如果设置了环境变量
PAGER
,则输出将通过管道传递到指定程序。
否则,将使用依赖于平台的默认值(例如more
)。
\pset option [ value ]
[...]
pager
Controls use of a pager program for query and psql help output. If the environment variablePAGER
is set, the output is piped to the specified program. Otherwise a platform-dependent default (such asmore
) is used.
当 pager
选项关闭,不使用寻呼机程序。启用分页器选项后,将在适当的情况下使用分页器
When the pager
option is off, the pager program is not used. When the pager option is on, the pager is used when appropriate
因此您可以从 psql中说出这一点
提示:
psql> \pset pager off
关闭寻呼机。如果希望始终应用此功能,则可以在〜/ .psqlrc
文件中添加 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.
您还可以使用 psql
\? >提示以快速获取您可以使用的特殊命令的摘要。
You can also use \?
from the psql
prompt to get a quick summary of the special commands at your disposal.
这篇关于在psql中自定义传呼机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!