GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add UseOSCIndicator setting to enable progress indicator in terminal by SteveL-MSFT · Pull Request #14927 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Mar 1, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

Add new $PSStyle.Progress.UseOSCIndicator setting 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, uses ESC]9; as a notification OSC sequence so you get a pop-up dialog instead of progress.

This is enabled as part of PSAnsiProgress experimental feature

image

cc Dustin L. Howett (@DHowett)

PR Context

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s): PSAnsiProgress
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed: Doc new $PSStyle.Progress.UseOSCIndicator setting MicrosoftDocs/PowerShell-Docs#7304
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
  • Tooling
    • I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    • OR
    • I have considered the user experience from a tooling perspective and opened an issue in the relevant tool repository. This may include:
      • Impact on PowerShell Editor Services which is used in the PowerShell extension for VSCode
        (which runs in a different PS Host).
        • Issue filed:
      • Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        • Issue filed:
      • Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
        • Issue filed:
      • Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
        • Issue filed:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Andrew (anmenaga) and Dongbo Wang (daxian-dbw) as code owners March 1, 2021 15:04
@ghost ghost assigned Andrew (anmenaga) Mar 1, 2021
@SteveL-MSFT Steve Lee (SteveL-MSFT) mentioned this pull request Mar 1, 2021
Doc new $PSStyle.Progress.UseOSCIndicator setting MicrosoftDocs/PowerShell-Docs#7304
Closed
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the progress-indicator branch 4 times, most recently from 52fae7c to 0dd98b0 Compare March 1, 2021 15:19
@bergmeister

Christoph Bergmeister (bergmeister) commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

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.
Therefore what do you think about a best effort approach of trying to detect well known terminals like ConEmu or the Windows terminal and have a different default if and only if it can be detected with confidence.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Mar 1, 2021

Copy link
Copy Markdown
Member Author

Christoph Bergmeister (@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JustinGrote

Justin Grote (JustinGrote) commented Mar 2, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT) Christoph Bergmeister (@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.

SteveL-MSFT reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Steve Lee (SteveL-MSFT) added 3 commits March 5, 2021 14:08
@SteveL-MSFT
Add $PSStyle.Progress.UseOSCIndicator to enable progress indicator …
004a0ea
…in terminal
@SteveL-MSFT
fix codefactor issue
63635c1
@SteveL-MSFT
fix and move comment
18cc947
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the progress-indicator branch from df71565 to 18cc947 Compare March 5, 2021 22:08
daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Mar 11, 2021
View reviewed changes
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Mar 11, 2021

Copy link
Copy Markdown
Member

Steve Lee (@SteveL-MSFT) It would be nice if you can add screenshot or GIF to show how this looks in Windows Terminal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daxian-dbw
Dongbo Wang (daxian-dbw) reviewed Mar 11, 2021
View reviewed changes
Comment thread src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs
}

// OSC sequence to turn on progress indicator
// https://github.com/microsoft/terminal/issues/6700

@daxian-dbw Dongbo Wang (daxian-dbw) Mar 11, 2021

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an official document for the OSC sequences supported in Windows Terminal?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Mar 11, 2021

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None I could find other than the github issue

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT @daxian-dbw
Update src/System.Management.Automation/FormatAndOutput/common/PSStyl…
5d9bd70
…e.cs

Co-authored-by: Dongbo Wang <[email protected]>
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Mar 11, 2021

Copy link
Copy Markdown
Member Author

Dongbo Wang (@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

anmenaga reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anmenaga
Andrew (anmenaga) approved these changes Mar 12, 2021
View reviewed changes

@anmenaga Andrew (anmenaga) left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@anmenaga Andrew (anmenaga) added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log CL-Experimental Indicates that a PR should be marked as an Experimental Feature in the Change Log and removed CL-Experimental Indicates that a PR should be marked as an Experimental Feature in the Change Log labels Mar 12, 2021
@anmenaga Andrew (anmenaga) changed the title Add $PSStyle.Progress.UseOSCIndicator to enable progress indicator in terminal Add UseOSCIndicator setting to enable progress indicator in terminal Mar 12, 2021
@anmenaga

Andrew (anmenaga) commented Mar 12, 2021

Copy link
Copy Markdown

Changed PR title so that changelog generation script won't have problems with it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anmenaga
Andrew (anmenaga) merged commit c9d6506 into PowerShell:master Mar 12, 2021
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the progress-indicator branch March 12, 2021 03:31
@DHowett Dustin L. Howett (DHowett) mentioned this pull request Mar 12, 2021
Supporting the OSC 9;4 codes #14208
Closed
@ghost

Deleted user (ghost) commented Mar 16, 2021

Copy link
Copy Markdown

🎉v7.2.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

  • Release Notes
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sdwheeler Sean Wheeler (sdwheeler) mentioned this pull request Mar 22, 2021
Add UseOSCIndicator setting to enable progress indicator in terminal MicrosoftDocs/PowerShell-Docs#7372
Closed
@sba923

Stéphane BARIZIEN (sba923) commented Apr 18, 2021

Copy link
Copy Markdown
Contributor

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:

  1. a;b;c;d one-liner where a sets the indicator to "indeterminate" using OSC9;4;3;100BEL, b launches a script that uses Write-Progress, c performs some time-consuming actions, and d resets the indicator using OSC9;4;0;100BEL: the "indeterminate" indicator is overwritten by the Write-Progress so during the execution of c the indicator is not the "indeterminate" one but the "0%" one
  2. If a script shows its progress using Write-Progress and uses Compress-Archive, the indicator set by the former is overwritten by the one set by the latter, so the indicator that's visible most of the time is 0% since that's what it's reset to at the end of the Compress-Archive

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DHowett

Dustin L. Howett (DHowett) commented Apr 18, 2021

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sba923

Stéphane BARIZIEN (sba923) commented Apr 19, 2021

Copy link
Copy Markdown
Contributor

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 a / d parts of my scenario #1 covered?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT
Add UseOSCIndicator setting to enable progress indicator in terminal (P…
bf45556
…owerShell#14927)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
+1 more reviewer
@anmenaga Andrew (anmenaga) anmenaga approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@anmenaga Andrew (anmenaga)

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@SteveL-MSFT @bergmeister @JustinGrote @daxian-dbw @anmenaga @sba923 @DHowett
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.