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 22:03:05 -0700	[thread overview]
Message-ID: <561DE209.9060804@eastlink.ca> (raw)
In-Reply-To: <151013172339.ZM30911@torch.brasslantern.com>

On 10/13/2015 05:23 PM, Bart Schaefer wrote:
> What defines a "hit" here?  Your "history" command isn't "searching"
> AT ALL.  Rather it's your series of "grep" commands that are doing
> the searching.  There's no way an argument to the "history" command
> can tell it how many times "grep" of its output is going to succeed.
Yes, how silly of me. history by itself knows nothing of my grepping.  
Duhhhh.
> So it sounds like what you really want is
>
>      eval history -r -n -$HISTSIZE $sstring | head $nnumber
>
> That is, dump the entire history, grep it, and then show the most
> recent few events that match the greps.
Sure, but I was hoping for something a little more delicate.
The -m switch does do some internal finding, so maybe that's the
starting point. Couldn't history count it's matches when the '-m' is used?

     history -M$nnumber "*$sstring"*" ... or something.

Never mind tho.  Working from your example above I come up with:

     $ history -n -m "*$sstring*" 1 | tail -n $nnumber | grep 
--color=auto "$sstring"

And it's very satisfactory.  She burns through the entire history so fast
that there's nothing to complain about.   Thanks Bart.



  reply	other threads:[~2015-10-14  5:03 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 [this message]
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=561DE209.9060804@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).