erdtree
erdtree copied to clipboard
Can 'erd' offer a 'du'-replacement features for '--summarize', '--block-size' and pipeline-able stdout?
Might features similar to du's -s, -h, -B, -m be available, now or in the future?
These du features are remarkably valuable to me. Could be pretty neato to include in erdtree, maybe... if feasible? Maybe y'all are already handling/thinking about this?
(I did not see anything after a quick, lazy look through erd --help and https://github.com/solidiquis/erdtree README ... apologies if I missed something already documented.)
Here's my du's info/help/version, for potentially-handy reference:
$ du --version | ag core
du (GNU coreutils) 9.3
$
$ du --help
Usage: du [OPTION]... [FILE]...
or: du [OPTION]... --files0-from=F
Summarize device usage of the set of FILEs, recursively for directories.
Mandatory arguments to long options are mandatory for short options too.
-0, --null end each output line with NUL, not newline
-a, --all write counts for all files, not just directories
--apparent-size print apparent sizes rather than device usage; although
the apparent size is usually smaller, it may be
larger due to holes in ('sparse') files, internal
fragmentation, indirect blocks, and the like
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'-BM' prints sizes in units of 1,048,576 bytes;
see SIZE format below
-b, --bytes equivalent to '--apparent-size --block-size=1'
-c, --total produce a grand total
-D, --dereference-args dereference only symlinks that are listed on the
command line
-d, --max-depth=N print the total for a directory (or file, with --all)
only if it is N or fewer levels below the command
line argument; --max-depth=0 is the same as
--summarize
--files0-from=F summarize device usage of the
NUL-terminated file names specified in file F;
if F is -, then read names from standard input
-H equivalent to --dereference-args (-D)
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
--inodes list inode usage information instead of block usage
-k like --block-size=1K
-L, --dereference dereference all symbolic links
-l, --count-links count sizes many times if hard linked
-m like --block-size=1M
-P, --no-dereference don't follow any symbolic links (this is the default)
-S, --separate-dirs for directories do not include size of subdirectories
--si like -h, but use powers of 1000 not 1024
-s, --summarize display only a total for each argument
-t, --threshold=SIZE exclude entries smaller than SIZE if positive,
or entries greater than SIZE if negative
--time show time of the last modification of any file in the
directory, or any of its subdirectories
--time=WORD show time as WORD instead of modification time:
atime, access, use, ctime or status
--time-style=STYLE show times using STYLE, which can be:
full-iso, long-iso, iso, or +FORMAT;
FORMAT is interpreted like in 'date'
-X, --exclude-from=FILE exclude files that match any pattern in FILE
--exclude=PATTERN exclude files that match PATTERN
-x, --one-file-system skip directories on different file systems
--help display this help and exit
--version output version information and exit
Display values are in units of the first available SIZE from --block-size,
and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000).
Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation <https://www.gnu.org/software/coreutils/du>
or available locally via: info '(coreutils) du invocation'
$
$ sw_vers
ProductName: macOS
ProductVersion: 12.6.5
BuildVersion: 21G531
$
$ type du
du is hashed (/opt/homebrew/opt/coreutils/libexec/gnubin/du)
$
You can get du's -s and -h behavior doing the following:
I don't currently support allowing people to specify a custom block-size, defaulting instead to 512-byte units, I'm guessing that's what you're after?
@solidiquis I don't seem to get your command erd -L1 -iH. work. Why target/ is still ignored here?
@liebkne do you perhaps have a config file that's using the --pattern to filter? If so could you try passing --no-config? It works for me
Let me know if the issue persists.
@solidiquis Hi, I don't have any config file.
Also, the Matching du output example in README does not seem to work for me.
@liebkne last question before I dig further.. are any of the following environment variables set for you?
DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE
The example quoted below is quite helpful, thanks @solidiquis.
After using erd a bit more, here's my list of things that would make it closer to "perfect" for me as a du replacement... I think. (I'm still learning erd.)
du --summarize .(to enable summarizing size of a single directory, with only one line of output)du --block-size [...](so: "yes, and then some" the answer to the question below)- option to appropriately format
erd'sstdoutfor pipeline-stdin for other commands, likesort; eg, eliminate the footer line(s), maybe other things? eg:du -sh * | sort -rnis something I've run regularly in the past; said example may be no longer needed witherd's built-in sort capability, but being pipeline-extendable for reasons that we can not fully predict now is possibly a useful thing for general adoption, replace-ability of other commands (likedu), scalability (oferd), etc. sort-able--color=forceoutput. This may only be an issue forsort(or any other next-in-the-pipeline command) rather thanerd. Comments or suggestions welcome.
You can get
du's-sand-hbehavior doing the following:I don't currently support allowing people to specify a custom block-size, [defaulting instead to 512-byte units](https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks), I'm guessing that's what you're after?
I'm highlighting @liebkne's question (above), in case it deserves its own issue or focus or some such.
@solidiquis I don't seem to get your command `erd -L1 -iH.` work. Why `target/` is still ignored here?
I don't currently support allowing people to specify a custom block-size, [defaulting instead to 512-byte units](https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks), I'm guessing that's what you're after?
@solidiquis I don't seem to get your command `erd -L1 -iH.` work. Why `target/` is still ignored here?