zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Ray Andrews <rayandrews@eastlink.ca>, Zsh Users <zsh-users@zsh.org>
Subject: Re: subsitutions and beginning of lines.
Date: Mon, 12 Oct 2015 17:42:29 +0100	[thread overview]
Message-ID: <20151012174229.10eafc03@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <561BD771.6000006@eastlink.ca>

On Mon, 12 Oct 2015 08:53:21 -0700
Ray Andrews <rayandrews@eastlink.ca> wrote:

> On 10/11/2015 07:26 PM, Daniel Shahaf wrote:
> > You could avoid parsing the line numbers (and unescaping the commands) 
> > altogether by accessing the history differently: 
> 
> > % print -r - $history[1004] echo foo 
> 
> I could never get that to work with anything besides a single 
> subscript.  I'd expect it
> to drive like any other array but nothing seems to work:
> 
>      print -lr - $history[-5,-1]
> 
> ... and the point of what I'm doing is to show a range.

It's an associative array, so you need the exact index as a decimal with
no leading zeros; ranges and reverse indices don't work.

% print ${(t)history}
association-readonly-hide-hideval-special

But you can fake something like that above up:


local -a myhist=() indices=({$((HISTCMD-5))..$((HISTCMD-1))})
integer ind
for ind in $indices; do
  myhist+=(${history[$ind]})
done


pws


      reply	other threads:[~2015-10-12 16:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-11 19:12 Ray Andrews
2015-10-11 20:09 ` Peter Stephenson
2015-10-11 23:05   ` Ray Andrews
2015-10-12  9:34     ` Peter Stephenson
2015-10-12 15:44       ` Ray Andrews
2015-10-12 17:07         ` Ray Andrews
2015-10-13  2:29           ` Bart Schaefer
2015-10-13  2:50             ` Ray Andrews
2015-10-13  5:03               ` Bart Schaefer
2015-10-13  5:24                 ` Ray Andrews
2015-10-13 19:58                   ` Bart Schaefer
2015-10-13 21:42                     ` Ray Andrews
2015-10-14  0:23                       ` Bart Schaefer
2015-10-14  5:03                         ` Ray Andrews
2015-10-12  2:26 ` Daniel Shahaf
2015-10-12 15:53   ` Ray Andrews
2015-10-12 16:42     ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151012174229.10eafc03@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).