Cygwin“少”命令使 bash 忘记屏幕缓冲区历史记录

发布于 2024-11-26 03:01:47 字数 114 浏览 2 评论 0原文

当我运行“less”时,我的 Cygwin 终端出现一些问题。 “less”工作正常,但是当我退出它时,终端的所有屏幕缓冲区历史记录都会丢失。有什么建议吗?

我在 WinXP 上运行 Cygwin。

I'm having some issues with my Cygwin terminal when I run 'less'. 'less' works fine, but when I come out of it, all the screen buffer history of the terminal is lost. Any suggestions?

I'm running Cygwin on WinXP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寄意 2024-12-03 03:01:47

尝试以 less -X 运行,或将 LESS 环境变量设置为 -X

Try running as less -X, or set the LESS environment variable to -X.

撑一把青伞 2024-12-03 03:01:47

它与bash无关。被删除的是终端模拟器显示的文本。

与其他全屏程序一样,less 在启动时保存终端状态(包括任何显示的文本和光标位置),并在退出时恢复它。

它通过打印 smcuprmcup 定义的字符串来实现此目的 terminfo 条目。

这些取决于 $TERM 环境变量的值。

如果这些字符串打印,或者它们配置为不保存和恢复终端状态的内容,则 less 将替换屏幕上的任何内容通过您要查看的文件内容,然后不恢复它。

使用 -X 选项less(按照您接受的答案的建议< /a> 告诉 less 打印 smcuprmcup 字符串——我希望这会导致 想解决你想要解决的问题。

如果你 要保存和恢复终端状态(这意味着退出时 less 生成的输出将消失),您需要确保设置了 $TERM 环境变量到具有适当的 smcuprmcup 设置的东西,我发现将其设置为 xterm 通常有效,

如果您有雄心,您可以创建您的。拥有 terminfo 条目并使用 tic 命令 Dawid Ferenczy 的回答

提出了问题的另一个可能原因;我自己也遇到过这样的事。

(关于保存和恢复终端状态是否是一件好事,意见分歧很大。此博客条目 是由非常不喜欢它的人编写的,如果我想运行全屏命令并在做其他事情时保持其输出可见,我只需在中启动它即可。另一个窗口。)

(原始海报已经大约 2.5 年没有出现在该网站上,因此我们不应该期待任何反馈,但这些答案可能对其他人有用。)

It has nothing to do with bash. What's being erased is the text displayed by your terminal emulator.

Like other full-screen programs, less saves the terminal state (including any displayed text and the cursor position) when it starts, and restores it on exit.

It does this by printing the strings defined by the smcup and rmcup terminfo entries.

These depend on the value of the $TERM environment variable.

If these strings aren't printed, or if they're configured to something that doesn't save and restore your terminal state, then less will replace whatever was on your screen by the contents of the file you want to view, and then not restore it.

Using the -X option to less (as suggested by the answer you accepted tells less not to print the smcup and rmcup strings -- which I would expect to cause the problem you're trying to solve.

If you want to save and restore your terminal state (which means that the output produced by less will vanish when you quit), you need to make sure that your $TERM environment variable is set to something with proper smcup and rmcup settings. I find that setting it to xterm usually works.

If you're ambitious, you can create your own terminfo entry and use the tic command to "compile" it to the binary format used by the system.

Dawid Ferenczy's answer suggests another possible cause for the problem; it's not something I've ever run into myself.

(Opinions differ widely on whether saving and restoring the terminal state is a good thing. This blog entry was written by someone who intensely dislikes it. Personally, I like it; if I want to run a full-screen command and keep its output visible while I'm doing something else, I just launch it in another window.)

(The original poster hasn't been on the site in about 2½ years, so we shouldn't expect any feedback, but these answers are likely to be useful to others.)

偷得浮生 2024-12-03 03:01:47

我的新笔记本电脑也遇到了同样的问题。我在 64 位 Windows 7 上使用 Cygwin 已经很长时间了,从来没有遇到过这个问题。但在新的系统(也是 64 位 Windows 7)上,每当我退出 LESS、MAN、VIM 等时,具有相同配置的相同 Cygwin 都会清除屏幕缓冲区。这让我非常困扰。因为我在ConEmu终端仿真器中使用Cygwin,所以我怀疑ConEmu。经过几个小时比较所有可能的原因(环境变量、配置、软件版本等)后,我与 ConEmu 的作者进行了交谈(他真的很棒,对免费软件的支持堪称典范!)。我们终于找到了原因。

唯一的区别(或少数几个区别之一)在于显示尺寸。旧笔记本电脑的屏幕分辨率为 1366 x 768 像素,而新笔记本电脑的屏幕分辨率为 1920 x 1080。我使用整个屏幕作为终端窗口。这确实很奇怪,但是如果终端窗口高度大于 cca 62 行,则退出 LESS、VIM 等后屏幕缓冲区将被清除。无论 Cygwin 是在 ConEMu 内执行还是纯 cmd.exe 中执行。 缩小终端窗口解决了问题。 62 行的窗口高度对我来说似乎没问题。此外,对于一些较大的高度值,LESS 进程有时会崩溃。

看来这是Cygwin的问题。

您可以在此处阅读整个故事。

也许它可以帮助某人。我真的花了很多时间来解决这个问题。虽然解决方案(或者更确切地说是解决方法)是如此愚蠢:)

I had the same issue on my new laptop. I have been using Cygwin on the 64bit Windows 7 for a long time and I never experienced this problem. But on the new fresh system (also 64bit Windows 7) the same Cygwin with the same configuration cleared the screen buffer whenever I quit LESS, MAN, VIM etc. And it bothered me very much. Because I'm using Cygwin inside ConEmu terminal emulator, I suspected ConEmu. After a lot of hours comparing everything what potentially could be the cause (environment variables, configurations, software versions etc.), I had a conversation with the ConEmu's author (and he was really great, exemplary support for the free software!). And we finally found the cause.

The only difference (or one of few) was in the display size. The old laptop has a screen resolution of 1366 x 768 pixels, while the new one has 1920 x 1080. And I'm using the whole screen for the terminal window. It's really strange, but if the terminal window height is greater than cca 62 lines, the screen buffer is cleared after quitting the LESS, VIM etc. No matters if Cygwin is executed inside the ConEMu or plain cmd.exe. Making the terminal window smaller solved the problem. Window height of 62 lines seems to be fine for me. Also, with some of greater height values, the LESS process sometimes crashed.

It seems that it's a problem of the Cygwin.

The whole story you can read here.

Maybe it could help somebody. It took me really a lot of time to solve that. While the solution (or rather workaround) is such damn stupid :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文