Closed lzybkr closed 8 years ago
Thanks Jason, will do.
The format for TimeSpan is finished. I'm trying to get a format for DirectoryInfo and FileInfo, but I'm struggling.
Something like:
Mode LastWritten Length (MB) Name
---- ----------- ----------- ----
d----- 3 months ago addins
d----- 2 months ago appcompat
d----- 2 months ago AppPatch
d----- 23 hours ago AppReadiness
d-r--- 3 days ago assembly
d----- 3 months ago bcastdvr
Neat idea. PowerShell Community Extensions does the "Length (MB)" thing, but not the cool LastWritten.
You can look at how they did it: http://pscx.codeplex.com/
Getting closer. Works for either DirectoryInfo or FileInfo, but not both. Back to reading the help.
posh> ls -file
Mode LastWritten Length Name
---- ----------- ------ ----
-a---l 3 months ago 61 KB bfsvc.exe
-a--s- 6 hours ago 66 KB bootstat.dat
-a---- 6 days ago 10 KB cfgall.ini
-a---- 4 months ago 1 KB cfgrs.ini
-a---- 4 months ago 134 B cfgrs_ex.ini
-a---- 2 months ago 6 KB comsetup.log
Looking good
Look at C:\Windows\System32\WindowsPowerShell\v1.0\FileSystem.format.ps1xml - you'll see SelectionSetName - it lets you specify formatting for a group of related types. Also note EntrySelectedBy - this can be used to do formatting on just one of the types in the group.
It might be useful to add custom formatting for some types, e.g. TimeSpan. The default display for TimeSpan isn't that good, the Humanize method looks much better, Use case:
The output should be, well, humanized. In my own personal profile, I use something like: