zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: subsitutions and beginning of lines.
Date: Tue, 13 Oct 2015 14:42:12 -0700	[thread overview]
Message-ID: <561D7AB4.7030206@eastlink.ca> (raw)
In-Reply-To: <151013125819.ZM30782@torch.brasslantern.com>

On 10/13/2015 12:58 PM, Bart Schaefer wrote:
> The normal thing when capturing $(...) in an array context is to treat
> all adjacent (consecutive) whitespace (characters listed in $IFS) as a
> single word break, yes.  But the spaces aren't being "stripped down to
> a single one".  They're being stripped out ENTIRELY, leaving nothing.
> It's when putting the array back together into a string again that a
> single space is inserted between words.

Ah ... a subtle point but critical.  Yes ... I need to 'think array' not 
'think string'.
I apologize for my C headedness which refuses to go away.
>      ${${(f)"$(eval history $nnumber $sstring)"}##<->:}

I couldn't get the substitution there to work, but this works fine:

	print -l ${${(f)"$(eval history $nnumber $sstring)"}/ #<->??/}

... and I can see that the inner '$(eval ..)' layer will not
molest any spaces at all and each output line is an element unto
itself in an array split on newlines which is then sent for surgery
and then printed one line per element.  It's so easy to get it
wrong, but when you get it right, it's down right elegant and not
really obscure at all.

BTW, is there some way of asking history not to search
thru a given number of entries, but to continue searching up to
a given number of hits? Making syntax up:

history -#10 intricate_command

... I find when searching, that what I'm really wanting is a
reasonable number of hits to select from, and my choice of
number for the switch is just a guess which I scale up or
down to achieve some number of hits.  I might know that
some time in the last year I entered some command that I'd
like back and I don't really care how far back in history
it was, I just want history to scan backwards until
a match (or several) is found.  Can it be done? If not
it would be a feature.



  reply	other threads:[~2015-10-13 21:42 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 [this message]
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

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=561D7AB4.7030206@eastlink.ca \
    --to=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).