Add UseOSCIndicator setting to enable progress indicator in terminal#14927
Add UseOSCIndicator setting to enable progress indicator in terminal#14927anmenaga merged 4 commits intoPowerShell:masterfrom
Conversation
52fae7c to
0dd98b0
Compare
|
Whilst one wouldn't want things special cased and hard-coded to terminals, one can actually detect if PowerShell is hosted within ConEmu via environment variables. |
|
@bergmeister does ConEmu have a big enough customer base to warrant such code? Also, does every version of ConEmu support it? In the case of Windows Terminal, we'd have to check that it's newer than a specific version to turn it on by default. |
|
@SteveL-MSFT @bergmeister I worry about doing automatic terminal detection being a slippery slope of the team having to support all kinds of terminal quirks long-term, when it's easy enough to do the detection in a user profile. Especially when being done with something as arbitrary as environment variables vs. some sort of standard cross-platform terminal feature detection process (which doesn't exist to my knowledge) This kind of detection could also easily be done in a separate module that manages PSStyle, I don't think it should be part of the core PS codebase however. |
df71565 to
18cc947
Compare
|
@SteveL-MSFT It would be nice if you can add screenshot or GIF to show how this looks in Windows Terminal. |
src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| // OSC sequence to turn on progress indicator | ||
| // https://github.com/microsoft/terminal/issues/6700 |
There was a problem hiding this comment.
Is there an official document for the OSC sequences supported in Windows Terminal?
There was a problem hiding this comment.
None I could find other than the github issue
…e.cs Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
|
@daxian-dbw added a gif, you can see it in the upper left of the tab. It's just a little circle that fills in based on % complete |
$PSStyle.Progress.UseOSCIndicator to enable progress indicator in terminal|
Changed PR title so that changelog generation script won't have problems with it. |
|
🎉 Handy links: |
|
Given that the OSC progress indicator is a "write-only" thing, there are a number of scenarios where the result is not what one would expect IMVHO:
This can be experimented with something like this: param([int] $Count = 10, [int] $Delay = 10, [switch] $Archive)
for ($i=0; $i -lt $Count; $i++)
{
Write-Host ("{0}/{1}" -f $i, $Count)
Write-Progress -Activity 'Activity' -Status 'Status' -PercentComplete (100 * ($i+1) / $Count)
if ($Archive)
{
Remove-Item c:/tmp/foo.zip -ea 0
Compress-Archive -destination c:/tmp/foo.zip C:\Users\steph\OneDrive\Images\*.cr2
}
Start-Sleep -Seconds $Delay
}
Write-Progress -Activity 'Activity' -Status 'Status' -Completed
I think what we need is some global stack-based encapsulation of the indicator, where the latest desired indicator is "pushed" to the top of the stack, and the indicator is restored to the previous state on a "pop" operation. |
|
This needs to be solved for all nested and coterminous progress operations regardless of OSC indication. OSC indication being mixed up is only one symptom of the underlying issue. 😄 |
Where is discussed / tracked? Are the |
PR Summary
Add new
$PSStyle.Progress.UseOSCIndicatorsetting to use conemu's OSC indicator to show progress in the terminal window, which is also supported by Windows Terminal. Since this is a custom OSC that isn't widely supported, it defaults to$false. Since this is an advanced setting not supported by many terminals, had to give it a technical name. iTerm2, for example, usesESC]9;as a notification OSC sequence so you get a pop-up dialog instead of progress.This is enabled as part of
PSAnsiProgressexperimental featurecc @DHowett
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.PSAnsiProgress(which runs in a different PS Host).