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

Re: Remove multiple characters after match



Bart Schaefer schrieb am Mi 20. Dez, 14:28 (-0800):
> On Mon, Dec 18, 2023 at 11:34 PM Jörg Sommer <joerg@xxxxxxxx> wrote:
> >
> > How can I remove the spaces after the left delimiter?
> 
> You're trying to get the shortest match for (*) and the longest match
> for ( #), which doesn't work.

Ahh. That makes sense. Thanks for this explanation.

> % print -l -- -${(*)^${(*)${(*)x// #,, #/,,}#*,,}%,,*}-
> -*.i-
> -*.i-
> -*.i-
> -*.i-
> -*.i-
> -*.i-
> 
> You didn't actually say what output you wanted but I think that's it?

Yes, that's it. In the end I used this code to make entering for loops
easier, e.g. `git -C ,, ~/git/*(/),, grep …`. Zsh is really cool!

```
accept-line()
{
    case "$BUFFER" in
      *,,?*,,*)
        BUFFER="for i in ${${${BUFFER#*,,}## #}%% #,,*}; do ${BUFFER/,,?*,,/\$i}; done"
        ;;
    esac
    zle .accept-line
}
zle -N accept-line
```

Thanks and regards,

Jörg

-- 
> Ich kenn mich mit OpenBSD kaum aus, was sind denn da so die
> Vorteile gegenueber Linux und iptables?
Der Fuchsschwanzeffekt ist größer. :->
Message-ID: <slrnb11064.54g.hschlen@xxxxxxxxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature



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