When I use Get-ChildItem in PowerShell I get a list of items in a directory formatted in rows. This list often goes off screen, forcing me to scroll up if I want to see the rest of the list or previous commands and outputs. I want to make an alias or function for ls that behaves like ls in unix. I want a compact list of names that are formatted in a tabular fashion.
I have a function that I'm working on that strings all the names together, but it doesn't format the list in a table and does not prevent names from overflowing to the next line:
function uls {
(Get-ChildItem $args[0] | select -exp name) -join "`t"
}
In sum, is there a way to get a compact ls-like output from Get-ChildItem?
Use Format-Wide, which has a default alias of fw:
ls | fw
You can control the number of columns with the -Column property:
ls | fw -c 5
Just beware that the output of that command is a string, not a collection of objects, so it wouldn't be useful for pipelining.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With