Created
April 30, 2018 08:38
-
-
Save yoav-lavi/1253321d968db7f52d1a77ac48e3ff96 to your computer and use it in GitHub Desktop.
A spinner for PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Load { | |
param([scriptblock]$function, | |
[string]$Label) | |
$job = Start-Job -ScriptBlock $function | |
$symbols = @("⣾⣿", "⣽⣿", "⣻⣿", "⢿⣿", "⡿⣿", "⣟⣿", "⣯⣿", "⣷⣿", | |
"⣿⣾", "⣿⣽", "⣿⣻", "⣿⢿", "⣿⡿", "⣿⣟", "⣿⣯", "⣿⣷") | |
$i = 0; | |
while ($job.State -eq "Running") { | |
$symbol = $symbols[$i] | |
Write-Host -NoNewLine "`r$symbol $Label" -ForegroundColor Green | |
Start-Sleep -Milliseconds 100 | |
$i++ | |
if ($i -eq $symbols.Count){ | |
$i = 0; | |
} | |
} | |
Write-Host -NoNewLine "`r" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this mate.
I'm gonna use it in my project here https://github.com/regg00/ChocoMan/tree/main