Skip to content

compute directory sizes from contained files and directories - #1250

Merged
sophiajt merged 9 commits into
nushell:masterfrom
Amanita-muscaria:directory-size
Jan 26, 2020
Merged

sophiajt merged 9 commits into
nushell:masterfrom
Amanita-muscaria:directory-size

Conversation

@Amanita-muscaria

@Amanita-muscaria Amanita-muscaria commented Jan 20, 2020 •

Copy link
Copy Markdown
Contributor

resolves: #1242

ls --full will now show the total directory size as computed from all the contained files and folders recursively.

This has been the only time in my career where a recursive function was actually a good idea.

@gitpod-io

gitpod-io Bot commented Jan 20, 2020 •

Copy link
Copy Markdown

@sophiajt

Copy link
Copy Markdown
Contributor

I like it.

I wonder if this should go behind a new flag. Maybe --total to get directory totals. You might want to do full to get the extra information but not want to wait for the full totals (especially for big directories)

@Amanita-muscaria

Copy link
Copy Markdown
Contributor Author

I thought about that but I'd have to change the function declaration for each shell and only the filesystem shell actually needs this.

@thegedge

Copy link
Copy Markdown
Contributor

Sorry, I asked this question in the issue not realizing we already had a PR out:

One question I'd like to first ask: would it make more sense for us to build a du alternative instead of baking this into ls? More generally, should we take the UNIX philosophy with our tools and try to keep their complexity down by making them do one thing well?

I was wondering what we thought about those questions, since I think it sets a precedent that I want to make sure is the right one 🙂

@Amanita-muscaria

Copy link
Copy Markdown
Contributor Author

Personally, I don't mind either way. I can add a different command to do this just as easily as I've added it to ls.

@sophiajt

Copy link
Copy Markdown
Contributor

Sure, let's do it that way. @Amanita-muscaria - your point about adding it to all the shells is a good one. Want to take @thegedge's idea and turn this into a new du command?

@andrasio

Copy link
Copy Markdown
Member

Agree with all points stated. Thank you!!!

@Amanita-muscaria

Copy link
Copy Markdown
Contributor Author

Ya, I can do that.

@sophiajt

Copy link
Copy Markdown
Contributor

Looks good!

@sophiajt
sophiajt merged commit d48f99c into nushell:master Jan 26, 2020
@Amanita-muscaria
Amanita-muscaria deleted the directory-size branch April 7, 2020 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compute total size of all files/folders in directory rather than just directory's size

4 participants