%20%E8%B3%87%E6%96%99%E5%BA%AB%E6%99%82%E8%A1%A8%E7%8F%BE%E8%BC%83%E5%B7%AE%EF%BC%9F.png)
情境
zsh
殼,oh-my-zsh
框架,- 沒什麼特別的
zsh
配置postgresql
。
麻煩
我注意到一個惱人的行為:查詢資料庫時,例如:
SELECT * FROM mytable ;
它的行為與less
(with (END)
) 一樣,返回需要「關閉」less
(使用q
捷徑),這意味著我在鍵入下一個查詢時無法讀取上一個查詢的結果。
相反,bash
這種行為不是嗎:查詢後,顯示結果,並且可以鍵入下一個查詢。
問題
我怎樣才能定制zsh
它在這方面的表現bash
?
答案1
您可以通過評論完全關閉它
cat ~/.oh-my-zsh/lib/misc.zsh
...
#env_default 'PAGER' 'less'
#env_default 'LESS' '-R'
...
然後打開一個新終端再試一次;或者..
exec zsh (in the same terminal)
答案2
您的 shell 可能正在設定PAGER
環境變數。
嘗試在運行 psql 之前取消設定:
user@host% unset PAGER
您也可以嘗試從 postgresql shell 將分頁器 pset 值設為“off”,如下所示:
user=> \pset pager off
這將會開啟或關閉尋呼機的使用。您也可以將其設定為使用特定尋呼機(如more
、less
、cat
等)。
psql 手冊頁中的更多資訊:
pager
Controls use of a pager 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 is off, the pager is not used. When the pager is on,
the pager is used only when appropriate, i.e. the output is to a
terminal and will not fit on the screen. (psql does not do a perfect
job of estimating when to use the pager.) \pset pager turns the pager
on and off. Pager can also be set to always, which causes the pager to
be always used.