Would it be possible to include a --tree flag which produces output similar to tree? I saw this was briefly mentioned in #107, but the issue was actually about something else.
Thank you for your feedback.
Would it be possible to include a --tree flag which produces output similar to tree?
Why do you want this to be included? Do you see a strong use case for this?
It would certainly be possible somehow, but:
tree-like output would therefore require us to collect all results first before we could print anything.--absolute-path, --follow, --print0...) would have to be investigated.Overall, to be honest, I don't feel like this would be worth the effort.
Maybe a second program could help here. I tried to use fd .. | xargs with tree and exa --tree, but didn't get this to work.
The appeal to me is simply that it's nicer to view when there is a large number of results in multiple subdirectories. If it requires a large overhaul to existing code though then it sounds like a poor fit. I'll see if some concoction of shell scripting can produce the desired output.
Unfortunately, I think this is out of the scope for fd and could better be handled by a second, external program. I'm going to close this for now.
wave I build the suggested external program:
Very cool! Thanks for posting this here. If you want to add LS_COLORS support, you could use my lscolors crate as a library.
Note that there are some weird edge-cases (like filenames including newline-characters) which would not work when simply piping to as-tree. If you want to handle those, you could either add a -0 option (similar to xargs, find and fd) which would read \0-separated filenames instead of \n-separated ones.
Alternatively, you could also accept paths as arguments and use fd … -X as-tree instead of fd … | as-tree. This should also work with weird filenames. This would suffer from command-line argument length restrictions (see also: #410).
If you like, we could add a section to the README: https://github.com/sharkdp/fd#integration-with-other-programs
If you want to add
LS_COLORSsupport, you could use my lscolors crate as a library.
https://github.com/jez/as-tree/compare/jez-lscolors
^ I actually was working on that last night. I was meaning to say: it's a wonderful library! I'm so glad it exists. Simple to use and worked exactly as expected. Thanks for building it as a standalone library!
Note that there are some weird edge-cases
Thanks for the heads up, I'll consider adding a -0 flag or something.
If you like, we could add a section to the README
¯_(ツ)_/¯ I'm not opposed but I'd like to at least polish it a bit more if I were to add it there.
Thanks again, I'll keep you posted.
Ah, cool - thank you for the feedback!
Most helpful comment
👋 I built the suggested external program:
https://github.com/jez/as-tree