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

Re: history expansion



> Date: Tue, 30 Apr 2002 09:43:14 -0700 (PDT)
> From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
> To: Roman Neuhauser <neuhauser@xxxxxxx>
> cc: zsh users <zsh-users@xxxxxxxxxx>
> Subject: Re: history expansion
> 
> On Tue, 30 Apr 2002, Roman Neuhauser wrote:
> 
> > Is there a way ^foo^bar substitution could replace all occurrences of
> > foo in the preceding event like !!:gs/foo/bar/?
> 
> Not in the way you think, no.  ^foo^bar is, very literally, shorthand for
> !!:s^foo^bar -- there's no provision for inserting a `g' to the left of
> the leftmost carat.
> 
> However, you can always create a special ZLE widget.  The following is
> pretty much exactly what the history code does:
> 
> function insert-bangbang-gs-and-accept {
>     setopt localoptions noksharrays noshwordsplit
>     [[ $BUFFER[1] == $histchars[2] ]] && BUFFER='!!:gs'$BUFFER
>     zle .accept-line
> }
> zle -N insert-bangbang-gs-and-accept
 
    thanks, that's just what I needed.
    I use setopt histverify, so I changed the .accept-line to
    .expand-history. but this got me thinking: how would one check for
    an option value in a function?

-- 
FreeBSD 4.4-STABLE
2:50PM up 7 days, 5:15, 15 users, load averages: 0.17, 0.09, 0.02



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