Supporting the OSC 9;4 codes
See original GitHub issueSummary of the new feature/enhancement
As a user I want PowerShell to integrate with terminal features where it makes sense, especially when the terminal is providing integration with the host operating system. One such feature supported by ConEmu and Windows Terminal (as of 2020-11-18) is OS integration for visual progress indicators via OSC9;4
ANSI codes.
The Write-Progress
cmdlet should optionally emit a ConEmu-style OSC 9;4
progress ANSI code, controlled by a switch parameter like -EmitAnsiProgress
, and default to a global variable like $EmitAnsiProgressPreference
so that it can be enabled profile-wide.
Proposed technical implementation details (optional)
When enabled via the switch parameter or the global preference variable, Write-Progress
will emit the following OSC codes in the following circumstances:
`e]9;4;st;pr`e\
st |
Description | Circumstance |
---|---|---|
0 | remove progress | Write-Progress -Completed |
1 | set progress value to pr |
Write-Progress -PercentComplete <pr> |
3 | set taskbar to Indeterminate state | Write-Progress when no -PercentCompleted has been set previously |
An example of this behavior can be emulated by running the following PowerShell command in a terminal supporting the OSC 9;4
code:
0..100 |% {
Write-Host -NoNewline "`e]9;4;1;$_`e\";
Write-Progress -Activity Demo -PercentComplete $_;
Start-Sleep 0.1
}; Write-Host -NoNewline "`e]9;4;0`e\"; Write-Progress -Activity Demo -Completed;
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Something similar to–or exactly matching–this just landed with #14927
I’d say this is adequately resolved, thanks for following up @DHowett!