Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Returning last parameter of a history command
- X-seq: zsh-users 10755
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Returning last parameter of a history command
- Date: Fri, 22 Sep 2006 15:57:09 +0100
- In-reply-to: <Xns98469866682A5zzappergmailcom@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns98469866682A5zzappergmailcom@xxxxxxxxxxx>
zzapper wrote:
> Hi
>
> how should this done in zsh-speak
>
> history -n -1|sed 's/^.* //
>
> Where the sed returns the last parameter
zmodload -i zsh/parameter
print ${${(z)history[$((HISTCMD-1))]}[-1]}
Adjust the line number as necessary: it's $((HISTCMD-1)) when you're
getting the previous line at the prompt but it depends where you are
relative to the line being updated. Experiment.
Note that $history is an associative array; you need to get the line
number in the key exactly right.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author