Git Product home page Git Product logo

solidiquis / erdtree Goto Github PK

View Code? Open in Web Editor NEW
2.2K 2.2K 61.0 18.53 MB

A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.

Home Page: https://crates.io/crates/erdtree

License: MIT License

Rust 99.51% Shell 0.49%
cli command command-line command-line-tool du dua dust exa fd find ls rust tree wc

erdtree's Introduction

Solidiquis

Instagram | Linkedin

Xin chΓ o πŸ‘‹

My name is Benji and I am currently software engineer at a startup building large-scale time-series data ingestion pipelines for the purposes of telemetry, visualization, and anomoly detection in hardware. During my freetime I'm either actively developing erdtree, iterating on my configs, learning something new, or trying to find time to engage in my other wide range of hobbies.

If you're someone who is interested in getting into software development as someone who is self-taught (I'm self-taught), are looking for career advice, or simply want to talk about programming then feel free to reach out to me in my socials.

erdtree's People

Contributors

0323pin avatar adamniederer avatar brezak avatar bryceberger avatar cosmichorrordev avatar demilich1 avatar fawni avatar goggle avatar iquiw avatar jhscheer avatar jprochazk avatar jubalh avatar kp64 avatar m4rch3n1ng avatar masynchin avatar mikesmithgh avatar sanders41 avatar siqpush avatar solidiquis avatar sullivant avatar tlntin avatar tomlonergan03 avatar ulrichsg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

erdtree's Issues

Sort by filesize could be a good feature

The performance of this tools is great! Amazing~

If a sort option for this command can be added. It would be better. In many cases, we might want to find the largest file or directory. Sort function can save the time for users to check from top to button.

For example:

OPTIONS:

……
-s: Sorted by file size

[FEATURE] use `-L` flag for level

In tree, -L is used for specifying the depth of the tree. Currently -L flag is not used by et, so can et use both -L and -l for the level to match the convention?

thread 'main' panicked; symlink issue?

The et command works fine - except in my home directory:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/fs/erdtree/node.rs:271:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The only difference I can see is that my home directory has links from other directories. Like this:

lrwxrwxrwx@   19 dave dave 26 Feb  2022 Documents -> /foo/Documents
lrwxrwxrwx@   16 dave dave 10 Jan  2022 Downloads -> /blah/Downloads

Any other ideas? Let me know if you require additional information. Using version 1.20.

backtrace.txt

Regex may should be consider in the prefix exclustion

The -p options is used to exclude files or directories with some specified prefixes. But if some hidden or system files start with "." prefixes, they can't be ignored.

I guessed the match didn't use Regex?


[... tensorflow]$ erdtree -l 1 -p "."
. (228.41 MB)
β”œβ”€ CODE_OF_CONDUCT.md (5.37 KB)
β”œβ”€ .pylintrc (0 B)
β”œβ”€ .bazelversion (6 B)
β”œβ”€ tools (4.91 KB)
β”œβ”€ arm_compiler.BUILD (1.18 KB)
β”œβ”€ configure.py (53.52 KB)
β”œβ”€ LICENSE (15.50 KB)
β”œβ”€ configure (285 B)

[feature] binary prefixes

hello, thank you for making this program. i think it'd be a good idea for erdtree to support binary prefix, since other programs like du uses binary prefix as default like following:

 $ du --help
...
 --si              like -h, but use powers of 1000 not 1024

As recommended in IEC 80000-13, this command will report sizes using SI units rather than binary units.

also, could you point me in the direction of source where it states SI unit is preferred over binary units?

Definition of prefixes using powers of 10β€”in which 1 kilobyte (symbol kB) is defined to equal 1,000 bytesβ€”is recommended by the International Electrotechnical Commission (IEC)

i found relevent paragraph in byte, and it looks like it's for SI prefix using 1000 vs 1024, not that it's preferred to use SI unit over binary prefix.

WSL2 & Google Drive Shared Drives

I'm using:

  • WSL2
  • Windows 11 Pro version 22H2
  • Debian (Debian GNU/Linux 11 (bullseye))
  • Erdtree v 1.7.1
  • Google Drive (Windows application) version 72.0.3.0

Running erdtree in /mnt/g/Shared drives/$DRIVE appears to hang - I've outputted to a file and run tail on the file for 10 minutes and had no output. Seeing as there does not appear to be a verbose output, is there any other documentation you'd like?

Add support for installation via curl command

As a user, I would like to be able to install the erdtree CLI application using the curl command. This would allow me to easily download and install the application without having to download the binary file manually or other installation methods.

I would like to contribute to this feature by creating the installation script.

et crashes when --prune is combined with a non existing --glob

et crashes when --prune is combined with a non existing --glob, e.g.:

$ cargo run -- --no-config --level 1 --prune --glob "main.rs" tests/data
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/et --no-config --level 1 --prune --glob main.rs tests/data`
thread '<unnamed>' panicked at 'internal error: entered unreachable code: Try to access a freed node', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/indextree-4.6.0/src/node.rs:45:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', src/render/tree/mod.rs:156:24

[feature] Add `args_override_self(true)`

Reasoning: I would like to make an alias to change some default behavior (sort, prefixes (future), etc). However, supplying the same argument twice (et -s name -s size) is an error.

Current behavior: et -s name -s size will not execute, with the message (from clap) that --sort cannot be used multiple times.
Expected behavior: et -s name -s size will execute, and sort output by size.

(This is a 3 line change and I have a PR ready, just wanted approval first as stated in the readme)

Potential name clash

- to Reddit user `/u/lucca_huguet` (can be found as [luccahuguet](https://github.com/luccahuguet) on Github) for suggesting that the compiled `erdtree` binary be shorted to `et`.

Hi, I noticed erdtree is in the AUR and I installed it. Works very well, congrats!

As long-time user and collaborator to the Firejail project it didn't take long before creating a firejail profile for erdtree. That profile also works quite well, but then I hit a snag. Apparently the spreadsheet component of WPS Office is also called (and installed as) et.

Obviously that's not a problem for the erdtree dev(s) as such. I sure like short, easy to remember command names myself. Realizing what a name change of the binary entails, I don't want to suggest to do so. I just wanted to bring this to your attention.

[feature] Sort directories first

Γ€ la tree --dirsfirst, an option to sort directories above normal files.

In my view, there are two ways to implement this:

  • et --sort dir, a manually-implemented "sort by directory"
  • et --sort ... --dirs-first, an option for all sorting methods to sort directories first

I have both implemented, don't know which (if either) to make a pr for.

[Feature request] Displaying modification time

Hi!

I've been using erdtree for a bit of time now and I'm quite happy with it, thanks for making this tool :)

I have one request though: would it possible (don't if it is) to add an option to also display the modification time of elements? It'd very, very useful for me.

Currently I use fd ... -x ls -lhd but it is quite slow, especially compared to erdtree.

Provide option to print without colors

I want to use erdtree to print a project's folder structure and use it in README's, but the ANSI escape sequences make it unreadable.

Something like --no-colors or --plain would do the trick.

I'd be happy to work on this feature if that's alright.

[feature] Option to filter files

It would be nice to be able to do:

$ erdtree --filter <glob_pattern>
$ erdtree -f <glob_pattern>

For example,

$ erdtree -f !*.snap

Would filter all insta snapshot files, and

$ erdtree -f *.snap

Would only display the snapshot files.

It seems like the ignore crate already supports adding ignore overrides.

Would you accept a PR that implements this?

thread panics when called from root ('/') directory

I really like this program, just a (small?) issue I found:

when I do cd / and then et, I get this panic:

[tom@tom-pc ~]$ cd /
[tom@tom-pc /]$ et
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/erdtree-1.2.0/src/fs/erdtree/node.rs:220:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.20/src/walk.rs:1302:31
^C

hang with non-existant directories?

when given a directory that doesn't exist, erdtree seems to hang until it is terminated manually.

These are the last three lines displayed when running with strace:

getcwd("/home/arisun/Projects/andrea", 1024) = 29
readlink("/home/arisun/Projects/andrea/bogus", 0x7ffec44b6d50, 1023) = -1 ENOENT (No such file or directory)
futex(0x56497ab84a58, FUTEX_WAIT_BITSET_PRIVATE, 4294967295, NULL, FUTEX_BITSET_MATCH_ANY

I am running the latest release, 1.7.0 on Arch in case that matters

error: unexpected argument '--dir' found

config file: ~/.erdtreerc, as follow:

--level 1
--icons
--scale 3

-s size
--dirs-first

run: et SomeDir

error occured:

error: unexpected argument '--dir' found

  note: argument '--dirs-first' exists

Once I delete the .erdtreerc file, and run the equivalent command: et -l 1 --icons --scale 3 -s size --dirs-first SomeDir, everything works fine.

`--ignore-git` doesn't seem to work

running et with hidden files and ignore git doesn't seem to work. I looked into it but I couldn't track it down fully yet (I'm still trying to grok OverrideBuilder atm).

[bws:~/circadian_tools] avgday(+19/-0)+ Β± et -H --ignore-git
circadian_tools (220.02 KB)
β”œβ”€ src (6.18 KB)
β”‚  β”œβ”€ chrono.rs (2.01 KB)
β”‚  └─ lib.rs (4.18 KB)
β”œβ”€ .git (197.54 KB)
β”‚  β”œβ”€ FETCH_HEAD (96.00 B)
β”‚  β”œβ”€ packed-refs (112.00 B)
β”‚  β”œβ”€ refs (809.00 B)
β”‚  β”‚  β”œβ”€ remotes (399.00 B)
β”‚  β”‚  β”‚  └─ origin (399.00 B)
β”‚  β”‚  β”‚     β”œβ”€ tau (41.00 B)
β”‚  β”‚  β”‚     β”œβ”€ main (41.00 B)

Maybe this code here is getting called before the show-hidden-glob gets added so it basically gets overwritten?

if self.ignore_git {
    builder.add("!.git/**/*")?;
}

BUG REPORT: et doesn't shows mp4 files

My et doesn't shows mp4 files
Version: erdtree 1.6.0

❯ ls                                                                                      
'0001-FINAL [573011600].mp4'  '0003-FINAL [573012721].mp4'   lessons_links.txt
'0002-FINAL [573011998].mp4'  '0004-FINAL [573013069].mp4'   video_links.txt
❯ et                                                                                      
00-intro (709 B)
β”œβ”€ video_links.txt (328 B)
└─ lessons_links.txt (381 B)

fix config locations

i still do not understand what is the point of making $HOME more clutter to maintain, even when we try to make it Clean / Neat

issue is regarding config-location

  • $HOME/.erdtreerc
    make location good , i mean standards of unix as `.config/et/.etrc'

some work around or TIPS which i have been using to tackle it
in Window (coz i use it for now ) :(
in $profile put this
$env:ERDTREE_CONFIG_PATH="path/to/conf/"

in Unix
in .bashrc put
export ERDTREE_CONFIG_PATH=path

`--ignore-git-ignore` in erdtreerc is ignored

To reproduce, put --ignore-git-ignore in $HOME/.erdtreerc.

Then run et from a directory that has some gitignored files. They won't be printed.

For comparison, if the flag is supplied through command line: et --ignore-git-ignore, it works as expected.

> et --version
erdtree 1.4.1

Add winget support

Now that winget is the official package manager for Windows, it would be useful to use winget since it's already pre-installed for Windows machines.

v1.3.0 is unable to build from source on windows via cargo install+ crates.io with rust 1.67.1 stable

Hello!

Thanks for continuing to improve this tool It's one of my favorites πŸ™‚

After trying to upgrade to erdtree 1.3.0 with cargo install via crates.io, I got the following error output (placed inside a <details> block for brevity, with truncated path)

error[E0425]: cannot find value `metadata` in this scope
  --> ${HOME}\.cargo\registry\src\github.com-1ecc6299db9ec823\erdtree-1.3.0\src\fs\inode.rs:54:13
   |
54 |             metadata.file_index(),
   |             ^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
1  | use core::ptr::metadata;
   |
1  | use std::fs::metadata;
   |
1  | use std::ptr::metadata;
   |

error[E0425]: cannot find value `metadata` in this scope
  --> ${HOME}\.cargo\registry\src\github.com-1ecc6299db9ec823\erdtree-1.3.0\src\fs\inode.rs:55:13
   |
55 |             metadata.volume_serial_number(),
   |             ^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
1  | use core::ptr::metadata;
   |
1  | use std::fs::metadata;
   |
1  | use std::ptr::metadata;
   |

error[E0425]: cannot find value `metadata` in this scope
  --> ${HOME}\.cargo\registry\src\github.com-1ecc6299db9ec823\erdtree-1.3.0\src\fs\inode.rs:56:13
   |
56 |             metadata.number_of_links(),
   |             ^^^^^^^^ not found in this scope
   |
help: consider importing one of these items
   |
1  | use core::ptr::metadata;
   |
1  | use std::fs::metadata;
   |
1  | use std::ptr::metadata;
   |

error[E0425]: cannot find value `nlink` in this scope
  --> ${HOME}\.cargo\registry\src\github.com-1ecc6299db9ec823\erdtree-1.3.0\src\fs\inode.rs:58:42
   |
58 |             return Ok(Self::new(md, dev, nlink));
   |                                          ^^^^^
   |                                          |
   |                                          a field by this name exists in `Self`
   |                                          help: a local variable with a similar name exists: `nlinks`

error[E0308]: mismatched types
  --> ${HOME}\.cargo\registry\src\github.com-1ecc6299db9ec823\erdtree-1.3.0\src\fs\inode.rs:58:33
   |
58 |             return Ok(Self::new(md, dev, nlink));
   |                       --------- ^^ expected `u64`, found struct `Metadata`
   |                       |
   |                       arguments to this function are incorrect
   |
note: associated function defined here
  --> ${HOME}\.cargo\registry\src\github.com-1ecc6299db9ec823\erdtree-1.3.0\src\fs\inode.rs:18:12
   |
18 |     pub fn new(ino: u64, dev: u64, nlink: u64) -> Self {
   |            ^^^ --------

Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `erdtree` due to 5 previous errors
error: failed to compile `erdtree v1.3.0`, intermediate artifacts can be found at `${HOME}\AppData\Local\Temp\cargo-installK25LHL`

To replicate this, I simply use cargo install erdtree

Publish to crates.io?

Hello!

This is a really fantastic tool. I was wondering if there's any hope of possibly publishing this to crates.io?

Feature idea: folders only

Use case: you have a small number (dozens) of folders, each of which may contain thousands of files. They may be at different depths, e.g.

a/{1k files}
a/b/{1k files}
b/c/d/{1k files}

in which case you might want a report like

β”œβ”€ a (123.45 MiB)
β”‚  β”œβ”€ b (67.89 MiB)
β”œβ”€ b (234.56 MiB)
β”‚  β”œβ”€ c (56.78 MiB)
β”‚  β”œβ”€ β”œβ”€ d (8.90 MiB)

For cases like this, would be real nice to have "dirs only" flags (e.g. -D / --dirs-only).

Apologies in advance if this is already doable and I have missed it.

--suppress-size still recursively computes file sizes even when sorting is disabled

I'm a simple man. I like pretty colors and file icons. So I installed this to replace tree and exa. I put up an alias to run et -i -I -s size -l 2. all nice and pretty.

Then I tried running the command at my root directory with and realized that wait, this is a tool that was made to calculate disk usage, not just print pretty trees! It took longer than necessary to just print 2 layers of folders.

So I tried --suppress-size. Still, it took the same amount of time.
So then I thought this was using the size data to possibly sort the files. I checked the source code and, yeah, it holds the data until it tries to sort. But it would be niceβ„’ with

struct Context {
    // ...
    #[arg(short, long)]
    max_depth: Option<usize>,
}

impl Context {
    // ...
    fn max_depth(&self) -> usize {
        self.max_depth.unwrap_or(usize::MAX)
    }

    fn walk_depth(&self) -> usize {
        self.max_depth().max(self.level())
    }
}

and a little bit of WalkBuilder::max_depth() in TryFrom<&Context> for WalkParallel then account for max_depth < level by setting the file sizes of deeper folders to 0 and hopefully done?

Now this should let you look at the shallow sizes of directories, if ever that's a thing that you need to do.

`--dirs-first` flag does nothing if no SortType is specified

for example: et --dirs-first will not sort directories above files, but if sort type is specified: et --dirs-first -s name it works as expected.

i was able to produce the expected behavior by adding a None enum variant to SortType and adding:

} else if ctx.dirs_first() {
	Order::from((SortType::None, true))
		.comparator()
		.map(|func| current_node.sort_children(func));
}

to this line, but there are probably "cleaner" approaches.

also, i noticed that clippy suggests a bunch of stylistic refactors all over. do you have an opinion against such stylistic approaches?

Does erdtree have a configuration file or environment variable?

I'm getting used to erdtree and liking what I'm seeing. I usually run it as et --icons or et --icons --dirs-first, etc.

So now I'm wondering: Is there some file or variable I can set that sets the "default" options for et? That is, export ERDTREE=--icons ... or an .erdtreerc or .config/erdtree.toml or such file where I could put in my "always show icons" options?

I know I can make an alias, but, well, if there's a more "canonical" way of doing this, I'd prefer that.

Feature idea: files count

Idea: a flags that enables reporting total file count for directories,

Could be especially useful with #84, so you could report files count like

β”œβ”€ a (123.45 MiB, 123 files)
β”‚  β”œβ”€ b (67.89 MiB, 67 files)
β”œβ”€ b (234.56 MiB, 234 files)
β”‚  β”œβ”€ c (56.78 MiB, 56 files)
β”‚  β”œβ”€ β”œβ”€ d (8.90 MiB, 8 files)

This might be somewhat confusing because it's not the number of files in a given directory but rather total files in this directory and all subdirectories (but is otherwise consistent with total file size being reported recursively).

Error when directory contains too much directories and files

$ erdtree -l 1

thread 'main' panicked at 'called Result::unwrap() on an Err value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/file_tree/tree_node.rs:48:51
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

[Feature request:] Pruning (when filtering using glob, don't print the empty branches)

I really like erdtree, here is little idea that I came across while using erdtree to search for files on my disk.

As the title says, it would be useful to enable "pruning" so the output only contains branches that aren't empty at the end.

Example:
let's say we have directory:

 folder_a
β”œβ”€  folder_b
β”‚  β”œβ”€ ο…› file_d (0.00 B)
β”‚  β”œβ”€ ο…› file_c (0.00 B)
β”‚  β”œβ”€  folder_ba
β”‚  β”‚  └─ ο…› file_x (0.00 B)
β”‚  β”œβ”€  folder_bc
β”‚  β”‚  └─ ο…› file_z (0.00 B)
β”‚  └─  folder_bb
β”‚     └─ ο…› file_y (0.00 B)
β”œβ”€ ο…› file_a (0.00 B)
β”œβ”€  folder_c
β”‚  β”œβ”€ ο…› file_ab (0.00 B)
β”‚  β”œβ”€ ο…› file_ac (0.00 B)
β”‚  β”œβ”€ ο…› file_ad (0.00 B)
β”‚  β”œβ”€ ο…› file_f (0.00 B)
β”‚  └─ ο…› file_e (0.00 B)
└─ ο…› file_b (0.00 B)


and I want to filter for files that contains "a": et -g "file_*a*" and the output is:

 folder_a
β”œβ”€  folder_b
β”‚  β”œβ”€  folder_bc
β”‚  β”œβ”€  folder_ba
β”‚  └─  folder_bb
β”œβ”€ ο…› file_a (0.00 B)
└─  folder_c
   β”œβ”€ ο…› file_ab (0.00 B)
   β”œβ”€ ο…› file_ac (0.00 B)
   └─ ο…› file_ad (0.00 B)

but with the "pruning" enabled, it would skip the "dead-ends" and print just:

 folder_a
β”œβ”€ ο…› file_a (0.00 B)
└─  folder_c
   β”œβ”€ ο…› file_ab (0.00 B)
   β”œβ”€ ο…› file_ac (0.00 B)
   └─ ο…› file_ad (0.00 B)

The idea is that when searching through bigger trees, the dead-ends are cluttering the output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.