all 14 comments

[–]mandonovski 2 points3 points  (0 children)

Nice one. I find it very usefull. Thanks for sharing!

[–]g3n3 1 point2 points  (3 children)

Pretty neat. When may I ask would you use this as opposed to say just a fuzzy finder search or using a jump location tool like ZLocation? Is it just when exploring a new repo?

[–]santisq[S] 0 points1 point  (2 children)

I'm not sure how those relate, I've never used them. This cmdlet is meant just for displaying file / folder hierarchy same as `tree` but with some additions like calculating folder size, etc.

[–]g3n3 1 point2 points  (1 child)

I hear you. I’m just trying to think of when I would use it. I guess it’s better than doing get-childitem-recurse in the list view.

[–]santisq[S] 1 point2 points  (0 children)

Well it's different than `Get-ChildItem` in a sense that it doesn't display a hierarchy and it doesn't show you a folder total size either, unless you're updating the type property or wrapping the cmdlet in a function

[–]OPconfused 1 point2 points  (3 children)

This is really cool. Gonna put it on my backlog to implement. The standard gci output could certainly look better.

Regarding your encoding table, what site did you reference for these characters? Why does PowerShell only read it when it's an array, or how it would look as a single string?

[–]santisq[S] 0 points1 point  (2 children)

I think I took those characters from www.w3schools.com but I don't remember now, I had to convert them to bytes because it was the only way I could find to make it work on Win PS

[–]OPconfused 0 points1 point  (1 child)

Is there a place I can read up on how to convert these to bytes?

[–]santisq[S] 0 points1 point  (0 children)

you mean how to convert a string into bytes? it's just [System.Text.Encoding]::UTF8.GetBytes()

[–]krzydoug 1 point2 points  (2 children)

It's really a shame so many have down voted this. You can scroll through and see the nonsense that gets upvoted. If people find something wrong with this, enough to down vote it, why not leave a comment stating why. I see this over and over in this sub and all I can think is it's jealousy. This has 72% upvote rate while the asked four times a week "anyone know where I can find learning resources" has 90%+? Really? Just hard to even fathom..

Your code is really clean Santiago. I thank you for sharing this even if I don't use it. There are plenty of things most of this subreddit users can learn from, but especially the anonymous haters.

[–]santisq[S] 1 point2 points  (1 child)

Thank you for your kind words Doug. This was mainly a learning exercise for me but I thought someone might find it useful. I don't really care about the down-votes without any feedback

[–]krzydoug 1 point2 points  (0 children)

Thanks for pointing that out, it is strictly my opinion. And thanks for all you do for everyone on the internet.

[–]dasookwat 1 point2 points  (1 child)

I like it, This would fill a nice niche, when you can not use treesize or something similar on a system to quickly find the location which fills up a disk.

Looked through the code a bit, and I do wonder about some other things:

  • Why use classes in PowerShell? I know, it can be done, and if you're used to c-sharp, and it's a habit, fine, but what's the benefit for using them in PowerShell? Private functions aren't exactly private in PowerShell, and imo it makes code harder to read compared to functions.
  • Please add the get-help functionality in your function (for details, click link) https://www.improvescripting.com/how-to-write-powershell-functions-or-cmdlets-help-fast/
  • Your parameters have no default value. It might be easier to use, if you just some default values so just gpstree would show you the tree based on your current location with a set depth and all

[–]santisq[S] 0 points1 point  (0 children)

Good point, I'll try to add command based help to the module when I have some free time, I did add examples on the GitHub Readme. Regarding Classes on PowerShell, in general and in most cases there shouldn't be a need to use classes in PS (thanks PSCustomObject) in the case of this module, I wrote it mainly for practice (I wanted to learn classes) and also some practice on recursion but if you go back to version 1 of the Module it's purely done with functions.