Get-ChildItemColor icon indicating copy to clipboard operation
Get-ChildItemColor copied to clipboard

Length-format differs

Open theuserbl opened this issue 3 years ago • 1 comments

There are some differences to Get-ChildItem.

A minor one is, that the date begins two spaces to early and the text "LastWriteTime" one space to early.

Harder is the complete "Length"-column: Directories, which having in Get-ChildItem no length-output and also on the cmd.exe dir command never hand an length, have in Get-ChildItemColor a length of 1. And bigger files are shown in "KB", "MB" and "GB", which makes them harder to differ, then giving out the exact byte-number of the file.

diff

theuserbl avatar Jul 05 '22 22:07 theuserbl

Ok, if I change in the file FileInfo.ps1 in the function Write-Color-LS the line

Write-host ("{0,10} " -f (Write-FileLength $item.length)) -NoNewline

to

 if ($color -ne "Blue") {
    Write-host ("{0,10} " -f $item.length) -NoNewline
 } else {
    Write-host ("{0,10} " -f "") -NoNewLine
 }

it helps for the Legth column. The formatting of the complete table is still not the same like in the original one, but it looks then a lot better. Before the directories are no number and the file size is as exact printed. But I don't know, why anybody have included Write-FileLength, which makes it incompatible to the original Get-ChildItem.

Also is my fix a little bit dirty, because it looks at the color. If anybody used an other color then blue for the directories, they have again a 1 before it. And if any body changed the color of any other file to blue, there don't will be shown the file size. But that is a quick and dirty hack. Don't know at the moment, how to find out at this place, if it is the length of an directory or an file.

diff2

theuserbl avatar Jul 06 '22 00:07 theuserbl