Skip to content

Instantly share code, notes, and snippets.

@yoav-lavi
Created April 30, 2018 08:38
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoav-lavi/1253321d968db7f52d1a77ac48e3ff96 to your computer and use it in GitHub Desktop.
Save yoav-lavi/1253321d968db7f52d1a77ac48e3ff96 to your computer and use it in GitHub Desktop.
A spinner for PowerShell
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"
}
@regg00
Copy link

regg00 commented Aug 16, 2023

Thanks for this mate.
I'm gonna use it in my project here https://github.com/regg00/ChocoMan/tree/main

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