Git bash intermittently won't clear screen when PS1 includes commands #20635

Open
opened 2026-01-31 07:19:42 +00:00 by claunia · 4 comments
Owner

Originally created by @Coridyn on GitHub (Oct 9, 2023).

Originally assigned to: @DHowett on GitHub.

Windows Terminal version

1.19.2682.0

Windows build number

10.0.22000.2416

Other Software

Git for windows: 2.42.0.windows.2

Steps to reproduce

  1. Start a terminal running git bash (%PROGRAMFILES%\\git\\bin\\sh.exe)

  2. Define a PS1 that echoes text to the screen:

PS1='$(echo -n "winterm echo> ")'
  1. Run some commands that output text to the screen:
$ ls
$ pwd
  1. Run clear to try and clear the screen contents:
$ clear
  1. Sometimes the screen won't clear and the previous text will remain displayed on screen

  2. When this happens, resizing the window or trying to select the text will clear the "ghost" text once, but the problem will continue to occur

Expected Behavior

The screen should be cleared and return to a blank prompt

e.g.

winterm echo>

Actual Behavior

Intermittently, the screen will not be cleared and the previous text will remain rendered to the screen.

windows-terminal-not-clearning


The issue does not occur for "simple" PS1 that doesn't echo text to the screen:

i.e. this PS1 works:

PS1='winterm noecho> '

this PS1 will fail intermittently:

PS1='$(echo -n "winterm echo> ")'

Other information:

Issue first seen in Windows Terminal Preview Version: 1.19.2682.0

Works correctly in Windows Terminal Version: 1.17.11461.0

Same issue occurs in Windows 10 and Windows 11
Windows 10: 10.0.19045.3448
Windows 11: 10.0.22000.2416

I have only observed this issue with Git for Windows gitbash when updating to Windows Terminal Preview Version: 1.19.2682.0 (was working previously, with no change to bitbash

Have not observed the issue with any other terminal: WSL Ubuntu, Powershell, Command Prompt

Originally created by @Coridyn on GitHub (Oct 9, 2023). Originally assigned to: @DHowett on GitHub. ### Windows Terminal version 1.19.2682.0 ### Windows build number 10.0.22000.2416 ### Other Software Git for windows: 2.42.0.windows.2 ### Steps to reproduce 1. Start a terminal running git bash (`%PROGRAMFILES%\\git\\bin\\sh.exe`) 2. Define a PS1 that echoes text to the screen: ``` PS1='$(echo -n "winterm echo> ")' ``` 3. Run some commands that output text to the screen: ``` $ ls $ pwd ``` 4. Run `clear` to try and clear the screen contents: ``` $ clear ``` 5. Sometimes the screen won't clear and the previous text will remain displayed on screen 6. When this happens, resizing the window or trying to select the text will clear the "ghost" text once, but the problem will continue to occur ### Expected Behavior The screen should be cleared and return to a blank prompt e.g. ``` winterm echo> ``` ### Actual Behavior Intermittently, the screen will not be cleared and the previous text will remain rendered to the screen. ![windows-terminal-not-clearning](https://github.com/microsoft/terminal/assets/1791456/da257cde-092f-440d-9511-a97f579975ec) ------------------------- The issue does not occur for "simple" PS1 that doesn't echo text to the screen: i.e. this PS1 works: ``` PS1='winterm noecho> ' ``` this PS1 will fail intermittently: ``` PS1='$(echo -n "winterm echo> ")' ``` ------------------------- Other information: Issue first seen in Windows Terminal Preview Version: 1.19.2682.0 Works correctly in Windows Terminal Version: 1.17.11461.0 Same issue occurs in Windows 10 and Windows 11 Windows 10: 10.0.19045.3448 Windows 11: 10.0.22000.2416 I have only observed this issue with Git for Windows gitbash when updating to Windows Terminal Preview Version: 1.19.2682.0 (was working previously, with no change to bitbash Have not observed the issue with any other terminal: WSL Ubuntu, Powershell, Command Prompt
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 07:19:42 +00:00
Author
Owner

@carlos-zamora commented on GitHub (Oct 11, 2023):

Thanks for filing! This might be related to how msys2 handles console modes. Would you be willing to capture a trace using this guide?

@carlos-zamora commented on GitHub (Oct 11, 2023): Thanks for filing! This might be related to how msys2 handles console modes. Would you be willing to capture a trace using [this guide](https://github.com/microsoft/terminal/wiki/Troubleshooting-Tips#capturing-a-debug-etl-trace)?
Author
Owner

@Coridyn commented on GitHub (Oct 12, 2023):

Sure, here's the trace: https://drive.google.com/file/d/1mDxIcmjiK21u8Ru_BwfVpQWeITCC4AGG/view?usp=sharing

Are you able to get it from that google drive share link?

@Coridyn commented on GitHub (Oct 12, 2023): Sure, here's the trace: https://drive.google.com/file/d/1mDxIcmjiK21u8Ru_BwfVpQWeITCC4AGG/view?usp=sharing Are you able to get it from that google drive share link?
Author
Owner

@DHowett commented on GitHub (Nov 1, 2023):

Hey @Coridyn, I got your trace! I'm so sorry - we didn't specify the instructions on the wiki particularly well. I never updated them when I added the new API call tracing.

Can you use these instructions instead and grab another trace?

  1. Same as previously - download Terminal.wprp
  2. wpr -start C:\path\to\Terminal.wprp!DefTerm.Verbose
    • The difference here is the profile name Terminal has been replaced with DefTerm; it enables more tracing.
  3. The rest of the steps are the same as well. 😆
@DHowett commented on GitHub (Nov 1, 2023): Hey @Coridyn, I got your trace! I'm so sorry - we didn't specify the instructions on the wiki particularly well. I never updated them when I added the new API call tracing. Can you use these instructions instead and grab another trace? > 1. Same as previously - download Terminal.wprp > 2. `wpr -start C:\path\to\Terminal.wprp!DefTerm.Verbose` > * The difference here is the profile name `Terminal` has been replaced with `DefTerm`; it enables more tracing. > 3. The rest of the steps are the same as well. :laugh:
Author
Owner

@Coridyn commented on GitHub (Nov 6, 2023):

Thanks for the updated instructions, here is the new trace:

https://drive.google.com/file/d/1o7Ut7jjqlbkIOkyTYiiqzEZqTDIWuEmT/view?usp=sharing

@Coridyn commented on GitHub (Nov 6, 2023): Thanks for the updated instructions, here is the new trace: https://drive.google.com/file/d/1o7Ut7jjqlbkIOkyTYiiqzEZqTDIWuEmT/view?usp=sharing
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20635