Skip to content

Instantly share code, notes, and snippets.

@t-mat
Last active June 17, 2024 10:51
Show Gist options
  • Save t-mat/2688905eac635b6aabfd41c33ca545ab to your computer and use it in GitHub Desktop.
Save t-mat/2688905eac635b6aabfd41c33ca545ab to your computer and use it in GitHub Desktop.
[Windows][Windows Terminal] Control Windows Terminal's progress bar from batch file

Default PowerShell

: Idle (default)
powershell -command " Write-Host -NoNewline ([char]27 + \"]9;4;3\" + [char]7) "

: WIP (rotation)
powershell -command " Write-Host -NoNewline ([char]27 + \"]9;4;0\" + [char]7) "

PowerShell7 (pwsh)

: Idle (default)
pwsh -command " Write-Host -NoNewline (\"`e]9;4;3`a\") "

: WIP (rotation)
pwsh -command " Write-Host -NoNewline (\"`e]9;4;0`a\") "

Pure batch file

for /F %%E in ('forfiles /m "%~nx0" /c "cmd /c echo 0x1b"') do set "_ESC=%%E"
for /F %%E in ('forfiles /m "%~nx0" /c "cmd /c echo 0x07"') do set "_BELL=%%E"

echo WIP (rotation)
echo %_ESC%]9;4;3%_BELL%

pause

echo Idle (default)
echo %_ESC%]9;4;0%_BELL%

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment