Skip to content

Instantly share code, notes, and snippets.

@dpo007
Last active August 27, 2020 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo007/816f7b809e3f4dbc76df84f89f7a699c to your computer and use it in GitHub Desktop.
Save dpo007/816f7b809e3f4dbc76df84f89f7a699c to your computer and use it in GitHub Desktop.
PowerShell function :: A simple console Write-Host animation
function DiscoWrite {
param (
[string]$str,
[int]$speed = 25,
[switch]$NoNewline
)
$anim = @('.', '-', '+', '*', '#')
[int]$CursorTop = [Console]::CursorTop
foreach ($letter in $str.ToCharArray()) {
[int]$CursorLeft = [Console]::CursorLeft
foreach ($frame in $anim) {
Write-Host $frame -NoNewline
[Console]::SetCursorPosition($CursorLeft, $CursorTop)
Start-Sleep -m $speed
}
Write-Host $letter -NoNewline
}
if (!$NoNewLine) {
Write-Host
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment