-
Notifications
You must be signed in to change notification settings - Fork 9.2k
ANSI character codes displayed on prompt after piping output through less #8525
Copy link
Copy link
Closed
Labels
Needs-Tag-FixDoesn't match tag requirementsDoesn't match tag requirementsResolution-ExternalFor issues that are outside this codebaseFor issues that are outside this codebase
Description
After piping git log | less and then pressing Q to quit, the PowerShell prompt displayed in Windows Terminal shows character codes, instead of being colored.
Environment
Windows build number: 10.0.19042.0
Windows Terminal version (if applicable): 1.4.3243.0
Any other software?
PowerShell Core: 7.1.0
Steps to reproduce
-
Open PowerShell Core in Windows Termianl
-
Set the prompt to be colored with ANSI escape codes:
function prompt { "`e[38;2;0;255;0mMyPrompt`e[0m>" } -
Run git log | less. Using full paths here:
& 'C:\Program Files\Git\bin\git.exe' log | & 'C:\Program Files\Git\usr\bin\less.exe' -
Press Q to quit log.
Expected behavior
Should see "MyPrompt>" in green.
Actual behavior
Prompt looks like this:
←[38;2;0;255;0mMyPrompt←[0m>
Workaround
The problem does not occur if Control+C is used to quit less.exe instead of Q.
The problem does not occur if Out-Host -Paging is used instead of less.exe.
& 'C:\Program Files\Git\bin\git.exe' log | Out-Host -Paging
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs-Tag-FixDoesn't match tag requirementsDoesn't match tag requirementsResolution-ExternalFor issues that are outside this codebaseFor issues that are outside this codebase