jez / as-tree Goto Github PK
View Code? Open in Web Editor NEWPrint a list of paths as a tree of paths 🌳
License: Other
Print a list of paths as a tree of paths 🌳
License: Other
Hi,
I have an old linux distribution that does not come with GLIBC_2.18. So the linux binaries archive does not work for me.
Would it be possible to add a release target that either compiles with GLIBC statically? Or alternatively, a MUSL target, which seems to be a static build anyway, similar to ripgrep or fd ?
When finding paths with find
and fd
, I often pipe the results into a script I wrote called pathsort
that groups files before directories.
Piping the output of pathsort
into as-tree
has no effect, as as-tree
sorts its input.
It would be nice if as-tree
had an option to group files before directories.
Gnu ls
has the --group-directories-first
option. tree
has the --dirsfirst
option. A long flag like those would be fine, but a one letter short flag would be ideal. Neither has an option to group files first.
For list output, I can see both groupings to be useful, but the existing tools only offer directories first.
For find and tree output, for some reason grouping files before directories makes more sense to me. I'm not sure why. Maybe it's because once you've seen the files in the directory, you can be done thinking about that directory for the remainder of the output.
This is my pathsort
script:
#!/bin/sh
set -euo pipefail
# 1. Replace the last `/` with `/ /`
# 2. Sort
# 3. Replace the `/ /` with `/`
pathsort()
{
sed -E 's/(.*)\//\1\/ \//' | sort | sed -E 's/(.*)\/ \//\1\//'
}
case "${1-}" in
-fd )
# It would be nice if `fd` had an option to prepend `./` to all relative paths,
# so that all paths have at least one `/` in them.
sed 's/^/.\//' | pathsort
;;
* )
pathsort
;;
esac
I have this in my shell's rc
file:
fdtree() { fd . -H -E .git "$@" | as-tree ; }
I've been using fdtree
more than tree
lately because I can write fdtree -E aaa -E bbb
to exclude using multiple patterns, while tree
can only have one -I
ignore pattern.
Thanks for as-tree
. I love it!
If fdfind folder_name
returns a empty output | as-tree
prints a new-line. Is it possible to not make it print new-line?
Actual behavior:
$ fdfind folder_name # returns no solution
$ fdfind folder_name | as-tree
$
Wanted behavior:
$ fdfind folder_name # returns no solution
$ fdfind folder_name | as-tree
$
I realy like the feature but it's strength would potentiate if you could use any character as an separator.
If you would e.g. print out JSON as dot-separated string (https://github.com/tomnomnom/gron) you could than view the whole thing as an tree
It would be interesting to include in the README any differences between as-tree
and tree -C --fromfile .
, since tree
is already packaged by many (most?) distributions. The only one immediately apparent to me is a slight performance gain:
$ wc -l ls.list
84758 ls.list
$ hyperfine --warmup 3 'cat ls.list | tree -C --fromfile .' 'cat ls.list | as-tree'
Benchmark #1: cat ls.list | tree -C --fromfile .
Time (mean ± σ): 571.0 ms ± 5.6 ms [User: 571.4 ms, System: 32.9 ms]
Range (min … max): 562.2 ms … 580.9 ms 10 runs
Benchmark #2: cat ls.list | as-tree
Time (mean ± σ): 454.3 ms ± 7.8 ms [User: 349.1 ms, System: 131.4 ms]
Range (min … max): 443.1 ms … 471.9 ms 10 runs
Summary
'cat ls.list | as-tree' ran
1.26 ± 0.02 times faster than 'cat ls.list | tree -C --fromfile .'
Hi
This is not an issue but just a query.
I just recently came across this repository and was excited to test it.
However, there doesn't appear to be any Windows binaries release I could take out for a spin.
I briefly tried installing via rust/cargo but quickly ran into some errors.
Is there support (or at least a plan) for Windows ?
An option to group directories first, like the GNU ls
option would be a nice addition:
--group-directories-first
group directories before files;
Are there any plans to provide a compiled version via Homebrew for Mac Users?
Line 24 in 01253c2
Is it a good idea to store this token in .travis.yml? Wouldn't it be better to use an environment variable which you can store on travis?
To reproduce, any of these commands cause a thread panic when piping the output of as-tree
to a pager (tested with less
, more
, most
, bat
):
ls /usr/lib | as-tree | less
(same when replacing less
with more
, most
, bat
, etc)
fd | as-tree | bat
fd | as-tree | cat | less
With RUST_BACKTRACE=1, the trace output is:
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1021:9
stack backtrace:
0: rust_begin_unwind
at /build/rust/src/rustc-1.49.0-src/library/std/src/panicking.rs:495:5
1: std::panicking::begin_panic_fmt
at /build/rust/src/rustc-1.49.0-src/library/std/src/panicking.rs:437:5
2: std::io::stdio::print_to
at /build/rust/src/rustc-1.49.0-src/library/std/src/io/stdio.rs:1021:9
3: std::io::stdio::_print
at /build/rust/src/rustc-1.49.0-src/library/std/src/io/stdio.rs:1033:5
4: as_tree::PathTrie::_print
5: as_tree::PathTrie::_print
6: as_tree::PathTrie::_print
7: as_tree::main
Hi,
thanks to fd
, I have found as-tree
which is very nice (and works well on Windows with cargo install -f --git https://github.com/jez/as-tree
).
Very nice that it can work with text:
>"A/B/C" | as-tree.exe
A/B
└── C
Could there be options to get if the use case is not rare enough?
A
└── B
└── C
(I was surprised by the mixture of single line common parts at first run).
Would it be possible to precise separator/delimiter, default being "/" (Maybe not as it works well with default \
on Windows/PowerShell) but for any other sequence separated by :,.
in cas the tool is used in other context?
C:/
seems displayed like so: C:/\
.
Thanks
Hey folks!
I like this package. It can be pretty useful sometimes. Are there any plans on creating an AUR package?
Would you please publish it to crates.io? It would make it much easier to install, I use an automated script for such cases.
This looks like a very useful tool. Any chance of releasing a build for Windows (e.g. Cygwin)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.