zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: [[ 'abcde' =~ (#i)Bcd ]]
Date: Tue, 8 Nov 2022 05:32:09 -0800	[thread overview]
Message-ID: <4ab5bc12-7b60-0478-8b79-72e3319dcb64@eastlink.ca> (raw)
In-Reply-To: <CAN=4vMp071_rBgV+noQN9L4nGQ3Oz56si_bnbUU4gQBk1MZHtw@mail.gmail.com>



>> local vvar=$( basename $cc[$aa] 2> /dev/null )
> There is a zsh way for this:
>
>    local var=${cc[$aa]:t}
>
> "t" is short for tail. There is also "h" for head.

Thanks yes, I knew zsh could do it, the use of basename was just a 
fill-in.  Anyway you did the work for me just there.  But I was going to 
pattern match, seems as usual zsh has a better way.


> Here WILD suggests a wildcard (a.k.a. glob, a.k.a. pattern) match, but
> the code is doing a regex match. If your intention is to perform a
> wildcard/glob/pattern match, do this:

Thing is that I need both.  Sometimes I'm searching for directories in a 
saved list, sometimes searching out there in the real world of globbing 
the filesystem.  What I showed was the search in the saved list.  My 
directory stack is file based, universal and persistent sorta like the 
history list but sometimes I want to go looking out on the FS too.  So 
yeah, 8 combinations :(  You'd think it might be four since in the mind 
it feels like a text search in both situations.


>
> There might be a better way to do this which would take advantage of
> **/*. It's hard to say without knowing what you are trying to achieve.

It's a directory 'cd' from my personal stack sent to Sebastian's 
n_list() for graphical selection.  I can't live without it.  But I 
decided to add live 'cd' from the entire filesystem filtered via 
arguments and, as above, the four combinations and as you anticipate I 
ran into the mud expecting the syntax for the four combinations in the 
latter situation to be the same as the former but the latter is 'live 
globbing' whereas the former is just pattern matching in the lines of a 
file so they are chalk and cheese.   It seems to be working but there's 
always the next gotcha:

     1 /aWorking/Zsh/Source/Wk 0 $ . c; c ,a zsh

     Searching entire system for directories matching "zsh" (BROAD):

... gives this n_list() screen:

-------------------------------------------------------------------------------------------------------

: Most recently visited directories matching "zsh" (BROAD):

/aWorking/Backup/Zsh
/aWorking/Zsh-55555
/aWorking/Zsh
/usr/share/zsh
/aWorking/garbageZSH
/aWorking/Zsh/Zsh-5.8
/usr/share/doc/zsh-common

: System wide directories matching "zsh" (BROAD):

/aMisc/Backup-root-2022-10-11/.thunderbird/i3n1gea2.Default 
User/Mail/Local Folders/ZSH.sbd
/aWorking/Backup/Zsh
/aWorking/Backup/Zsh/Zsh-5.8
/aWorking/Backup/Zsh/Zsh-5.8/share/zsh
/aWorking/garbageZSH
/aWorking/Zsh
/aWorking/Zsh-55555
/aWorking/Zsh/Zsh-5.8
/aWorking/Zsh/Zsh-5.8/share/zsh
/etc/zzsh
/root/.thunderbird/i3n1gea2.Default User/Mail/Local Folders/ZSH.sbd
/usr/lib/x86_64-linux-gnu/zsh
/usr/lib/x86_64-linux-gnu/zsh/5.8/zsh
/usr/local/share/zsh
/usr/share/doc/zsh
/usr/share/doc/zsh-common
/usr/share/zsh
/usr/share/zsh/functions/Completion/Zsh

-------------------------------------------------------------------------------------------------------------

... cursor up,  cursor down, pick a directory, press ENTER and you're 
there automagically.

Or I can demand an exact search (no card sharping, no advice on how to 
be insensitive):


1 /aWorking/Zsh/Source/Wk 0 $ . c; c ,Xa zsh
Searching entire system for directories matching "zsh" (EXACT):

------------------------------------------------------------------------------------------------------------------

: Most recently visited directories matching "zsh" (EXACT):

/usr/share/zsh

: System wide directories matching "zsh" (EXACT):

/aWorking/Backup/Zsh/Zsh-5.8/share/zsh
/aWorking/Zsh/Zsh-5.8/share/zsh
/usr/lib/x86_64-linux-gnu/zsh
/usr/lib/x86_64-linux-gnu/zsh/5.8/zsh
/usr/local/share/zsh
/usr/share/doc/zsh
/usr/share/zsh

--------------------------------------------------------------------------------------------------------------------

... so far, so good.





  reply	other threads:[~2022-11-08 13:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 21:10 Ray Andrews
2022-11-07 21:26 ` Roman Perepelitsa
2022-11-07 21:47   ` Ray Andrews
2022-11-07 22:15     ` Lawrence Velázquez
2022-11-08  1:57       ` Ray Andrews
2022-11-07 21:50   ` Lawrence Velázquez
2022-11-08  2:05     ` Ray Andrews
2022-11-08  8:19       ` Roman Perepelitsa
2022-11-08 13:32         ` Ray Andrews [this message]
2022-11-08 14:37           ` Roman Perepelitsa
2022-11-08 14:30             ` Ray Andrews
2022-11-08 17:40 ` Phil Pennock
2022-11-08 18:43   ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ab5bc12-7b60-0478-8b79-72e3319dcb64@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).