Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: history expansion
- X-seq: zsh-users 4919
- From: Roman Neuhauser <neuhauser@xxxxxxx>
- To: zsh users <zsh-users@xxxxxxxxxx>
- Subject: Re: history expansion
- Date: Mon, 6 May 2002 14:51:57 +0200
- In-reply-to: <Pine.LNX.4.44.0204300927430.13668-100000@xxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20020430163319.GV325@xxxxxxxxxxxxxx> <Pine.LNX.4.44.0204300927430.13668-100000@xxxxxxxxxxxxxxxx>
> 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