Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Length-format differs #48

Open
theuserbl opened this issue Jul 5, 2022 · 1 comment
Open

Length-format differs #48

theuserbl opened this issue Jul 5, 2022 · 1 comment

Comments

@theuserbl
Copy link
Contributor

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
Copy link
Contributor Author

theuserbl commented Jul 6, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant