Last active
June 8, 2019 18:20
-
-
Save LawrenceHwang/b28e20b44eac077f09148782f13ff586 to your computer and use it in GitHub Desktop.
ColourfulProgressBar.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$max = 600 | |
(1..$max).foreach{$x1 = Get-Random -Minimum 0 -Maximum ([math]::ceiling($host.ui.RawUI.WindowSize.Width* ($_/$max))); $x2 = $x1 + 1; $y1 = Get-Random -Minimum 0 -Maximum 1; $y2 = $y1 ;$Host.ui.RawUI.SetBufferContents([System.Management.Automation.Host.Rectangle]::new($x1,$y1,$x2,$y2),([System.Management.Automation.Host.BufferCell]::new([char](Get-Random -Minimum 32 -Maximum 33),([System.ConsoleColor].GetEnumValues() | Get-Random),([System.ConsoleColor].GetEnumValues() | Get-Random),[System.Management.Automation.Host.BufferCellType]::Complete)))} |
Thank you Jeff! Yes this only outputs to the top of existing console buffer and the long line is waaaay less readable. I will make the improvements you mentioned in next revision(s).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This didn't do anything unless I cleared the host first. It would also be nicer if you formatted the code as something other than a one-line expression.