You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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/shset -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
Off topic
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!
The text was updated successfully, but these errors were encountered:
Thanks. I mostly don't work on this project anymore, because tree has a --fromfile option built in that behaves just as well or better than as-tree. You can use tree --dirsfirst --fromfile instead.
When finding paths with
find
andfd
, I often pipe the results into a script I wrote calledpathsort
that groups files before directories.Piping the output of
pathsort
intoas-tree
has no effect, asas-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:Off topic
I have this in my shell's
rc
file:I've been using
fdtree
more thantree
lately because I can writefdtree -E aaa -E bbb
to exclude using multiple patterns, whiletree
can only have one-I
ignore pattern.Thanks for
as-tree
. I love it!The text was updated successfully, but these errors were encountered: