Screen clearing in CMD without "Legacy Console Mode"

Kevin Locke kevin@kevinlocke.name
Fri Apr 30 15:02:49 GMT 2021


On Fri, 2021-04-30 at 23:53 +0900, Takashi Yano wrote:
> On Fri, 30 Apr 2021 08:25:12 -0600 Kevin Locke wrote:
>> I'm investigating an issue in Git for Windows[^1], which also affects
>> Cygwin.  The issue is that, when using CMD (i.e. Command Prompt) on
>> Windows 10 1703 or above with "Legacy Console Mode"[^2] disabled, if
>> TERM=cygwin is set in the environment, the console is not cleared when
>> vi exits.  To demonstrate, with Cygwin 3.2.0, in CMD with "Legacy
>> Console Mode" disabled:
>> 
>> cd C:\cygwin64
>> set TERM=cygwin
>> bin\vi etc\bash.bashrc
>> :q
>> 
>> After exiting vi, the console window has not been cleared and content
>> from etc\bash.bashrc remains visible, making further use of the console
>> difficult until cleared.
> 
> Why on earth do you want to set TERM=cygwin?
> If you don't set TERM=cygwin, TERM is automatically set to
> xterm-256color, in which the issue does not occur.

Unfortunately, I am not clear on that myself.[^6]  According to Johannes
Schindelin[^7]:

> We specifically set TERM so that Cygwin (or more correctly, the MSYS2 runtime) uses ANSI sequences...

Hopefully he (or another of the Git for Windows contributors) can add
more specifics.

Thanks,
Kevin

[^6]: https://github.com/git-for-windows/git/issues/3177#issuecomment-828507812
[^7]: https://github.com/git-for-windows/git/issues/3177#issuecomment-826834976


More information about the Cygwin mailing list