开发者

Cygwin 'less' command makes bash forget screen buffer history

开发者 https://www.devze.com 2023-03-22 20:31 出处:网络
I\'m having some issues with my Cygwin terminal wh开发者_StackOverflow中文版en I run \'less\'. \'less\' works fine, but when I come out of it, all the screen buffer history of the terminal is lost. An

I'm having some issues with my Cygwin terminal wh开发者_StackOverflow中文版en 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.


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


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.)


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消