Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: retrieving the results of last command?
- X-seq: zsh-users 8876
- From: Peter Stephenson <pws@xxxxxxx>
- To: Zsh users list <zsh-users@xxxxxxxxxx>
- Subject: Re: retrieving the results of last command?
- Date: Fri, 20 May 2005 14:55:58 +0100
- In-reply-to: <237967ef05052006445c7578e9@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050520121834.GA32499@xxxxxxxxxx> <1049.1116593698@xxxxxxx> <237967ef05052006445c7578e9@xxxxxxxxxxxxxx>
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)"
}
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author