exa icon indicating copy to clipboard operation
exa copied to clipboard

How to Show Recursive Size of Directories?

Open amarakon opened this issue 2 years ago • 7 comments

When using '-l', exa only shows the size of files. It doesn't show the size of directories. I want it to show the size of the directories including the size of everything inside the directory (recursive) similar to the '--total-size' option in lsd which is a different alternative to ls.

amarakon avatar Feb 09 '22 01:02 amarakon

@Amarakon55 the case could be made then that exa would not be a drop-in replacement for ls if it does that work

Btw - this isn't the way a lot of operating systems behave out-of-the-box

There's a speed tradeoff as that would take the program time to add all the file sizes up in the directory trees under the current directory (as Linux / Debian systems don't do this by default - a gripe really for Linus Torvalds or the Canonical team)

Maybe someone can develop it as a flag option, as in "--show-directory-sizes"?

StewAlexander-com avatar Feb 21 '22 13:02 StewAlexander-com

Yes, it would be better if it wasn't the default behavior, but a flag option instead for those who want it.

amarakon avatar Feb 21 '22 23:02 amarakon

the other day I tested a whole slew of ls replacements and found one which has this feature, lsd. it is also written in rust I have no idea if helpful. I will definitely be keeping it around for this feature alone.

CouldBeThis avatar Mar 02 '22 00:03 CouldBeThis

There's a speed tradeoff as that would take the program time to add all the file sizes up in the directory trees under the current directory (as Linux / Debian systems don't do this by default - a gripe really for Linus Torvalds or the Canonical team)

Given that Exa already knows which nodes are directories and already knows the size content of files in those directories, I have trouble with the notion that simply summing all of the size values nested below a particular directory would be more than trivial.

faelin avatar Apr 19 '22 16:04 faelin

Given that Exa already knows which nodes are directories and already knows the size content of files in those directories, I have trouble with the notion that simply summing all of the size values nested below a particular directory would be more than trivial.

It’s easy to think something is trivial when you don’t know the code.

Exa doesn’t know the size of the files in the directories below, except when using recursive modes (like --long -tree), but sometimes you don’t go to the full depth, and you need to look up files you usually filter out (like hidden files, or files ignored by Git if you use --git-ignore) without displaying them; that’s not even considering the fact that it introduces a backtracking, which is to say that as of right now, exa can do the render for each file independently, but with this option, to know how to render folder line it needs to wait for everything inside it to have been checked, which would need some refactoring; and obviously it would need some serious testing with a lot of configuration.

So sure, additions are simple. But the change in question needs a lot of steps and require attention to a lot details that makes it complex.

ariasuni avatar Apr 29 '22 17:04 ariasuni

@ariasuni my apologies for the dismissive comment. You raise some excellent points, which I had not adequately considered.

Perhaps some day an additional feature can be implemented, that is specifically built to analyze disk usage, starting at the PWD.

faelin avatar Apr 29 '22 17:04 faelin

Thanks. Well new features can certainly be implemented and I plan to continue working on exa but I just don’t have enough time™ to make progress at a pace that satisfies people (and I understand that, but it’s frustrating for me as well and I can’t do much more than what I’m actually doing).

I’m not sure about this feature, especially the ratio asked for vs needed work, but I guess it could be done. Right now my main focus is merging some old PRs, improving the CI to not break things when merging big/ambitious changes, and triaging/answering the issues (actually most of my work is this latest one).

ariasuni avatar Apr 29 '22 17:04 ariasuni