Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: retrieving the results of last command?
- X-seq: zsh-users 8880
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh users list <zsh-users@xxxxxxxxxx>
- Subject: Re: retrieving the results of last command?
- Date: Sat, 21 May 2005 12:17:41 +0200
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LK0QtbTHFqX32LPtslWTMv7SKBycUK0XYdUz06MDR5OxTT4I8vkMCFy3IPJ6IcRGmjbtDpo38IN0Dtiw9W7wVMwt0mMaWjsJiGzsnlgp7PQRYgiKGSB8Fz8uPEjIyYCAPwyznuOrQVJmdvSzyl2kNqP72dJ29e3PpKKmyyKK4iU=
- In-reply-to: <200505201355.j4KDtxMm031147@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050520121834.GA32499@xxxxxxxxxx> <1049.1116593698@xxxxxxx> <237967ef05052006445c7578e9@xxxxxxxxxxxxxx> <200505201355.j4KDtxMm031147@xxxxxxxxxxxxxx>
- Reply-to: Mikael Magnusson <mikachu@xxxxxxxxx>
On 5/20/05, Peter Stephenson <pws@xxxxxxx> wrote:
> Mikael Magnusson wrote:
> > On 5/20/05, Peter Stephenson <pws@xxxxxxx> wrote:
> > > insert-last-command-output() {
> > > LBUFFER+=3D"$(eval $history[$((HISTCMD-1))])"
> > > }
>
> > Hello,
> > Is there a way to ask for confirmation here? It's not always history
> > contains what you expect, for example if you share history and just
> > ran rm -rf . in another terminal, and press this bind you might not be
> > so happy with the outcome. Ie something like
> > zsh: are you sure you want to run $history[$((HISTCMD-1))] again? [yn]
> > Is the read builtin what i want? I never quite got the hang of that one.
>
> With 4.2, the best way of prompting from within a command line is to use
> the supplied function read-from-minibuffer. Something like this:
>
> insert-last-command-output() {
> local hist=$history[$((HISTCMD-1))] REPLY
>
> autoload -U read-from-minibuffer
> read-from-minibuffer -k1 "Do you want to execute
> $hist
> again y/[n]? " || [[ $REPLY = [yY]* ]] || return 1
>
> LBUFFER+="$(eval $hist)"
> }
Thanks, that works fine (i assume the first || should be a && though).
(ps, sorry about the ccing on the last mail, gmail still does the
wrong thing when replying to a mailing lists and i didn't quite fix it
right.)
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author