在 psql 中自定义寻呼机 [英] customize pager in psql

查看:28
本文介绍了在 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 选项 [值]
[...]
寻呼机
控制寻呼机的使用用于查询和 psql 帮助输出的程序.如果环境变量PAGER 被设置,输出通过管道传送到指定的程序.否则使用依赖于平台的默认值(例如 more).

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.

pager 选项关闭时,不使用寻呼程序.当 pager 选项打开时,在适当的时候使用 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 提示符下说:

So you can say this from the psql prompt:

psql> pset pager off

关闭寻呼机.如果您希望它始终适用,您可以将 pset pager off 添加到您的 ~/.psqlrc 文件中.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆