以前,如果我运行something | less,然后按q,它曾经使我返回到提示,输出less仍然可见。
$ seq 1 100 | less
1
2
3
4
:q
$ <prompt here. I can still see the output of less>
Run Code Online (Sandbox Code Playgroud)
但是现在,在我安装了 Zsh(使用 oh-my-zsh。它也不适用于 bash)之后,终端看起来像这样:
$ seq 1 100 | less
<less shows up, I press :q and it is cleared>
$ <prompt here. Output of less disappears.>
Run Code Online (Sandbox Code Playgroud)
我搜索了一个less配置文件,但没有找到。有什么办法可以让我less按照以前的方式行事吗?使输出可见非常方便。
小智 9
seq 1 100 | less -X
Run Code Online (Sandbox Code Playgroud)
见:少人
-X or --no-init
Disables sending the termcap initialization and deinitialization strings to the terminal.
This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.
Run Code Online (Sandbox Code Playgroud)
正如 jhscheer 提到的,所有内容都在手册页中 less
将此添加到您的 zsh 配置文件中,.zshrc以使其与 git 一起使用 :)
LESS="-XRF"; export LESS
- 编辑
实际上,在您的情况下,最好运行以下命令以避免修改 的全局行为less:
git config --global core.pager 'less -XRF'