-
-
Notifications
You must be signed in to change notification settings - Fork 545
Expand file tree
/
Copy pathwrite-typewriter.ps1
More file actions
executable file
·31 lines (29 loc) · 815 Bytes
/
write-typewriter.ps1
File metadata and controls
executable file
·31 lines (29 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
.SYNOPSIS
Writes text like a typewriter
.DESCRIPTION
This PowerShell script writes the given text with the typewriter effect.
.PARAMETER text
Specifies the text to write (sample text by default)
.PARAMETER speed
Specifies the speed (200 ms by default)
.EXAMPLE
PS> ./write-typewriter.ps1 "Hello World"
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$text = "Hello World, this is the PowerShell typewriter.", [int]$speed = 200) # in milliseconds
try {
$Random = New-Object System.Random
$text -split '' | ForEach-Object {
Write-Host $_ -noNewline
Start-Sleep -milliseconds $Random.Next($speed)
}
Write-Host ""
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}