Updated write-typewriter.ps1

This commit is contained in:
Markus Fleschutz 2024-11-22 14:34:47 +01:00
parent bdc4cb1002
commit 6b2abf3103

View File

@ -1,27 +1,27 @@
<#
.SYNOPSIS
Writes text á la typewriter
Writes text like a typewriter
.DESCRIPTION
This PowerShell script writes the given text with the typewriter effect.
.PARAMETER text
Specifies the text to write
Specifies the text to write (sample text by default)
.PARAMETER speed
Specifies the speed (250 ms by default)
Specifies the speed (200 ms by default)
.EXAMPLE
PS> ./write-typewriter "Hello World"
PS> ./write-typewriter.ps1 "Hello World"
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$text = "`nHello World`n-----------`n* PowerShell is powerful - fully control your computer`n* PowerShell is cross-platform - available for Linux, Mac OS and Windows`n* PowerShell is open-source and free`n* PowerShell is easy to learn`n* PowerShell is fully documented`n`nThanks for watching`nMarkus`n", [int]$speed = 200) # in milliseconds
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 $(1 + $Random.Next($speed))
Write-Host $_ -noNewline
Start-Sleep -milliseconds $Random.Next($speed)
}
Write-Host ""
exit 0 # success