zsh-users
 help / color / mirror / code / Atom feed
* Zsh Rosetta Stone / ExplainShell equivalent
@ 2021-11-24  2:58 Zach Riggle
  2021-12-01  5:22 ` Daniel Shahaf
  2021-12-01 17:26 ` zzapper
  0 siblings, 2 replies; 6+ messages in thread
From: Zach Riggle @ 2021-11-24  2:58 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

Has anybody written a "zsh wtf" style tool where a complex expression is
annotated, similar to "explainshell.com"?

The more I learn about Zsh, the more obscure and hard-to-read my code is.

$ command date
Tue Nov 23 20:17:53 CST 2021


$ ls -la *(.Dmm-3)
-rw-r--r-- 1 zachriggle staff 0 Nov 23 20:17 file_10
-rw-r--r-- 1 zachriggle staff 0 Nov 23 20:15 file_8
-rw-r--r-- 1 zachriggle staff 0 Nov 23 20:16 file_9


Is definitely very convenient -- but only if you know what's going on.
Other, more documented commands can achieve roughly the same thing.


$ find . -Bmin -3 -type f -maxdepth 1 | xargs ls -la
-rw-r--r--  1 zachriggle  staff  0 Nov 23 20:17 ./file_10
-rw-r--r--  1 zachriggle  staff  0 Nov 23 20:15 ./file_8
-rw-r--r--  1 zachriggle  staff  0 Nov 23 20:16 ./file_9


Is there any interest in something like ExplainShell or ShellCheck for
Zsh?  I'm not sure what tools are best fit for parsing things like
complicated expressions.

*Zach Riggle*

[-- Attachment #2: Type: text/html, Size: 2118 bytes --]

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

* Re: Zsh Rosetta Stone / ExplainShell equivalent
  2021-11-24  2:58 Zsh Rosetta Stone / ExplainShell equivalent Zach Riggle
@ 2021-12-01  5:22 ` Daniel Shahaf
  2021-12-01 17:26 ` zzapper
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2021-12-01  5:22 UTC (permalink / raw)
  To: Zach Riggle; +Cc: Zsh Users

Zach Riggle wrote on Tue, Nov 23, 2021 at 20:58:52 -0600:
> $ ls -la *(.Dmm-3)
> Is there any interest in something like ExplainShell or ShellCheck for
> Zsh?  I'm not sure what tools are best fit for parsing things like
> complicated expressions.

Truncating the command line after each character and doing headless
completions (https://github.com/Valodim/zsh-capture-completion) might be
a good start.

For --options to builtins you could potentially make it a lot smarter by
looking in the manual sources.  Given «foo -x», jump to the
[a-z]index(foo) line, then show either the «item(tt(-x))», if there is
one, or the output of a sentence-wise grep for «tt(-x)» (taking the
parentheses as literals).

As to your question, you might've gotten better answers if you'd given
a self-contained description (or at least examples) of the proposed
functionality.

Cheers,

Daniel


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

* Re: Zsh Rosetta Stone / ExplainShell equivalent
  2021-11-24  2:58 Zsh Rosetta Stone / ExplainShell equivalent Zach Riggle
  2021-12-01  5:22 ` Daniel Shahaf
@ 2021-12-01 17:26 ` zzapper
  2021-12-01 18:40   ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: zzapper @ 2021-12-01 17:26 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 811 bytes --]


On 24/11/2021 02:58, Zach Riggle wrote:
> Has anybody written a "zsh wtf" style tool where a complex expression 
> is annotated, similar to "explainshell.com <http://explainshell.com>"?
>
> The more I learn about Zsh, the more obscure and hard-to-read my code is.
>
>     $ command date
>     Tue Nov 23 20:17:53 CST 2021
>
>
>     $ ls -la *(.Dmm-3)
>     -rw-r--r-- 1 zachriggle staff 0 Nov 23 20:17 file_10
>     -rw-r--r-- 1 zachriggle staff 0 Nov 23 20:15 file_8
>     -rw-r--r-- 1 zachriggle staff 0 Nov 23 20:16 file_9
>
>
Zach I recovered the following page from the old zsh Wiki website from 
the wayback machine


*http://zzapper.co.uk/charindex.html*
*
*
*I always found it useful for decoding zsh syntax*
*
*
*Along with*
*
*
*http://www.bash2zsh.com/zsh_refcard/refcard.pdf*
*
*
*zzapper
*
*
*
**

[-- Attachment #2: Type: text/html, Size: 3396 bytes --]

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

* Re: Zsh Rosetta Stone / ExplainShell equivalent
  2021-12-01 17:26 ` zzapper
@ 2021-12-01 18:40   ` Bart Schaefer
  2021-12-01 18:52     ` david rayner
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-12-01 18:40 UTC (permalink / raw)
  To: zzapper; +Cc: Zsh Users

On Wed, Dec 1, 2021 at 9:27 AM zzapper <zsh@rayninfo.co.uk> wrote:
>
> Zach I recovered the following page from the old zsh Wiki website from the wayback machine
>
> http://zzapper.co.uk/charindex.html

If anyone would like to update this I expect we could get it onto the
zsh.org website.

There are some obvious omissions even in the first few entries, for
example $'...' quoting which has been around for years.


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

* Re: Zsh Rosetta Stone / ExplainShell equivalent
  2021-12-01 18:40   ` Bart Schaefer
@ 2021-12-01 18:52     ` david rayner
  2021-12-01 19:38       ` Daniel Shahaf
  0 siblings, 1 reply; 6+ messages in thread
From: david rayner @ 2021-12-01 18:52 UTC (permalink / raw)
  To: zsh-users


On 01/12/2021 18:40, Bart Schaefer wrote:
> On Wed, Dec 1, 2021 at 9:27 AM zzapper <zsh@rayninfo.co.uk> wrote:
>> Zach I recovered the following page from the old zsh Wiki website from the wayback machine
>>
>> http://zzapper.co.uk/charindex.html
> If anyone would like to update this I expect we could get it onto the
> zsh.org website.
>
> There are some obvious omissions even in the first few entries, for
> example $'...' quoting which has been around for years.
>
Good idea If someone is able to do this I think they can just wget

http://zzapper.co.uk/charindex.html


The original page had some pretty complex css which I attempted to simplify.

zzapper



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

* Re: Zsh Rosetta Stone / ExplainShell equivalent
  2021-12-01 18:52     ` david rayner
@ 2021-12-01 19:38       ` Daniel Shahaf
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2021-12-01 19:38 UTC (permalink / raw)
  To: david rayner; +Cc: zsh-users

david rayner wrote on Wed, Dec 01, 2021 at 18:52:01 +0000:
> 
> On 01/12/2021 18:40, Bart Schaefer wrote:
> > On Wed, Dec 1, 2021 at 9:27 AM zzapper <zsh@rayninfo.co.uk> wrote:
> > > Zach I recovered the following page from the old zsh Wiki website from the wayback machine
> > > 
> > > http://zzapper.co.uk/charindex.html

Thanks for digging that up.

When I look up the definition of ${(X)} or ${foo[(X)]} or ${foo:X} or %X
or *(X) in the manual, I don't always remember whether the string to
grep for is a bare "X" (at the start of the line with whitespace after
it), or X with its "sigil", i.e., "(X)"/":X"/"%x".  The format of that
page solves this problem.

> > If anyone would like to update this I expect we could get it onto the
> > zsh.org website.

Yeah.  We could add it to the FAQ sources, so it'll be updated in
lockstep with everything else in zsh.git and be updated automatically
upon new releases — but see below.

> > There are some obvious omissions even in the first few entries, for
> > example $'...' quoting which has been around for years.
> > 
> Good idea If someone is able to do this I think they can just wget
> 
> http://zzapper.co.uk/charindex.html
> 
> 
> The original page had some pretty complex css which I attempted to simplify.

What's the copyright license of the contents of the original page?

Cheers,

Daniel


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

end of thread, other threads:[~2021-12-01 19:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24  2:58 Zsh Rosetta Stone / ExplainShell equivalent Zach Riggle
2021-12-01  5:22 ` Daniel Shahaf
2021-12-01 17:26 ` zzapper
2021-12-01 18:40   ` Bart Schaefer
2021-12-01 18:52     ` david rayner
2021-12-01 19:38       ` Daniel Shahaf

Code repositories for project(s) associated with this 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).