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

Re: [[ 'abcde' =~ (#i)Bcd ]]





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.







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