Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: alias hl='$(history -n -2 -2) '
- X-seq: zsh-users 9942
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx (Zsh users list)
- Subject: Re: alias hl='$(history -n -2 -2) '
- Date: Mon, 20 Feb 2006 11:18:48 +0000
- In-reply-to: <Xns976FBAFEAC071zzappergmailcom@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns976FBAFEAC071zzappergmailcom@xxxxxxxxxxx>
zzapper wrote:
> hi
>
> alias hl='$(history -n -2 -2) '
>
> The following attempts to emulate !-2 however if the command that is
> recalled is itself an alias, it fails to interpret the alias.
>
> Is this just hard-luck?
An overall summary is probably yes... The $(...) construct doesn't
cause the text it outputs to be completely reevaluated, just output
onto the command line as a set of words. This is substantially
different from what you want.
You could get the history part working better with
alias hl='eval "$(history -n -2 -2)" '
which takes the output from the history commands and treats it as a
command line (which is, of course, what it is). The problem is
that the eval applies to the entire line, including anything you type
after "hl ". I can think of nasty tricks involving functions to work
round that, but not any simple fix.
I presume you're trying to avoid bang-history for some reason. If you're
not wedded to aliases you could use a zle function to retrieve specific
stuff from the history.
--
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