How to display progress wheel in Terminal

Yes you read that title right. You can display a cool progress wheel in Terminal. You know Terminal, right? Right? Ok, then I just cut to the chase. The following PowerShell command will display a 50% completed wheel.
Write-Host -NoNewLine ([char]27 + "9;4;1;50" [char]7)

You see that tiny red half circle on the left corner of the title bar? That’s the wheel I’m talking about. Cool, right?
You can even do it in C# for your Console app.
Console.Write("\x1b]9;4;1;50\x07")
In PowerShell 7, you can simplify the command to:
Write-Host -NoNewline ("`e]9;4;1;50`a")
We are basically sending what's called OSC 9;4 sequence to the terminal. This sequence has the following syntax.
ESC ] 9 ; 4 ; <state> ; <progress> BEL
<state>
is a number between 0 and 4.
- 0 - will hide the progress wheel.
- 1 - will display the progress in default mode.
- 2 - will display the progress in error mode.
- 3 - will display the progress in indeterminate mode and ignore the
<progress>
. This one is actually cool. You'll see the result further below. - 4 - will display the progress in warning mode.
Let's try the "indeterminate" mode.
Write-Host -NoNewline ("`e]9;4;3;0`a")
