Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Any neat trick to convert print -rl -- **/** into a tree?



On 18 September 2016 at 00:51, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 17,  5:54pm, Sebastian Gniazdowski wrote:
> } Subject: Any neat trick to convert print -rl -- **/** into a tree?
> }
> } Hello,
> } I'm blank at this but seeing wc -c > 60 various surprising Zsh
> } expansions I suspect that it can be done: converting **/**
>
> Do you intend that second ** to be interpreted GLOB_STAR_SHORT, or
> is that a typo?

*/** didn't have expected effect so I went to **/**, didn't thought
about **/* :|

> } into a tree, i.e. into output that looks like e.g. output of tree
> } command
>
> It's difficult if not impossible to do this *during* the glob pass,
> because the sorting ends up confused, but if you capture the result
> in a variable:
>
>     () {
>       emulate -L zsh -o extendedglob
>       local x=(**/*)
>       print -l ${x//([^\/]##\/)/|- }
>     }
>
> Refine the replacement as desired.

Thanks!

Best regards,
Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author