zsh-users
 help / color / mirror / code / Atom feed
* Any neat trick to convert print -rl -- **/** into a tree?
@ 2016-09-17 15:54 Sebastian Gniazdowski
  2016-09-17 22:51 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-17 15:54 UTC (permalink / raw)
  To: Zsh Users

Hello,
I'm blank at this but seeing wc -c > 60 various surprising Zsh
expansions I suspect that it can be done: converting **/** into a
tree, i.e. into output that looks like e.g. output of tree command (OS
X):

├── LICENSE
├── Makefile
├── README.md
├── TODO
├── _n-kill
├── awk
│   ├── input
│   └── levdist.awk
├── doc
│   ├── generate_single_file
│   ├── img
│   │   └── n-history2.png
│   ├── install.sh
│   ├── n-preview
│   └── zshnavigationtools.plugin.zsh

Can it be done? The tree could use only indentation with spaces, or
"|". "\", "-" characters, or the box-drawing characters.

Best regards,
Sebastian Gniazdowski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Any neat trick to convert print -rl -- **/** into a tree?
  2016-09-17 15:54 Any neat trick to convert print -rl -- **/** into a tree? Sebastian Gniazdowski
@ 2016-09-17 22:51 ` Bart Schaefer
  2016-09-18  5:18   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2016-09-17 22:51 UTC (permalink / raw)
  To: Zsh Users

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?

} 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Any neat trick to convert print -rl -- **/** into a tree?
  2016-09-17 22:51 ` Bart Schaefer
@ 2016-09-18  5:18   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-18  5:18 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

On 18 September 2016 at 00:51, Bart Schaefer <schaefer@brasslantern.com> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-18  6:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-17 15:54 Any neat trick to convert print -rl -- **/** into a tree? Sebastian Gniazdowski
2016-09-17 22:51 ` Bart Schaefer
2016-09-18  5:18   ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).