eza-community / eza

A modern alternative to ls
https://eza.rocks
European Union Public License 1.2
11.98k stars 217 forks source link

Limit number of files printed per directory in tree mode? #1103

Open sainttttt opened 2 months ago

sainttttt commented 2 months ago

Hi! I was wondering if there's a way to limit the number of files printed out per directory in tree mode. There can be a case where one directory has a ton of files and most others don't and it messes up the whole output. Is this configurable at all? Are there any other utilities that do this perhaps?

Thanks!

cafkafk commented 2 months ago

Could be a useful feature, I don't know that we have something that do this.

I thought in general that would limit output to e.g. terminal width or some fix amount like

eza --limit-output 50
file
file
file 
[523 files skipped...]
file
file
file

Would be useful, if that also supported directories in tree output maybe that would be a really nice solution?

MartinFillon commented 1 month ago

If we implement this, should we keep the first n lines and last n lines ? Should we implement this on any options ?

jack-mil commented 1 month ago

would be a very cool feature, would make me less nervous about viewing large or unknown directories with --tree. Great for getting aquick understanding of the directory structure without flooding the terminal with long lists of files. 2-3 files per level would make sense. It could even scale so with a small number of files, all are show, but if the directory contains many, then elide/collapse into ... or something

sainttttt commented 1 month ago

@MartinFillon I think having an option for either first n lines only or first n and last n would be good. If I had to pick only one though I would go for first n and last n though, I think that gives it a better overview. It is what libraries like pandas does when printing a large dataframe.

MartinFillon commented 1 month ago

Well as per the current codebase design, implementing it for tree without computing all the lines will kinda be complex and need some thoughts to be put into it, for the other ways such as long I think it is indeed doable and a good idea, I am going to look into this when I have time.