By no means perfect but I am just playing here for fun trying to appease your odd but curious to me need
function get-easyview{
param([int]$Milliseconds= 50)
$text = $input | Out-String
[char[]]$text | ForEach-Object{
Write-Host -NoNewline $_
# Only break for a non-whitespace character.
if($_ -notmatch "\s"){Sleep -Milliseconds $Milliseconds}
}
}
Get-ChildItem | get-easyview -Milliseconds 50
This will take the input object and convert it into a single string that will then be case as a char
array. Then it will painfully display a single character at a time with a gap of X Milliseconds between characters. I wanted to shoot myself in the face using seconds. I hear a typewriter in my head watching this. Note: This only outputs to the host console and not the standard output stream. This would have to be the last pipe command. There is no usable -passthru
with this.
Can't find the reference but PowerShell can only go so slow. I don't think I could get the sleep between 1-20 milliseconds with a noticeable difference. I'm probably wrong with the numbers but it is a thing.
The output is not exactly as it is on screen. I'm working on it.
Don't you forget about More
Or the PowerShell equivalent out-host -paging
. Using Enter you can "absorb" the information at your own pace. Read more from this answer
Get-EasyView 2.0
I was playing more and I though about setting a switch so that you could go by character or line using some simple parameteres.
function get-easyview{
param(
[int]$Milliseconds= 50,
[ValidateSet("Line","Character")]
[String]
$Pace = "Character"
)
If($pace -eq "Character"){
$text = [char[]]($input | Out-String)
$parameters = @{NoNewline = $true}
} Else {
$text = ($input | out-string) -split "`r`n"
$parameters = @{NoNewline = $false}
}
$text | ForEach-Object{
Write-Host $_ @parameters
if($_ -notmatch "^\s+$"){Sleep -Milliseconds $Milliseconds}
}
}
So now you can do calls like this
Get-ChildItem | get-easyview -Milliseconds 50
Get-ChildItem | get-easyview -Milliseconds 1000 -Pace Line
Get-ChildItem | get-easyview -Milliseconds 50 -Pace Character