Skip to content

Instantly share code, notes, and snippets.

@t-mat
Last active January 18, 2025 05:45
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

@echo off
setlocal enabledelayedexpansion

set "CUR_DIR=%CD%"
cd /d "%~dp0"

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"

cd /d "%CUR_DIR%"

echo WIP (rotation)
echo|set /p=%_ESC%]9;4;3%_BELL%

pause

echo Idle (default)
echo|set /p=%_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