From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24544 invoked by alias); 14 Oct 2015 05:03:11 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20753 Received: (qmail 18955 invoked from network); 14 Oct 2015 05:03:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=TDXRqai3AtB4qfuLBL55xA==:117 a=TDXRqai3AtB4qfuLBL55xA==:17 a=N659UExz7-8A:10 a=W8APOwXpaew5jpowbecA:9 a=pILNOxqGKmIA:10 Message-id: <561DE209.9060804@eastlink.ca> Date: Tue, 13 Oct 2015 22:03:05 -0700 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: subsitutions and beginning of lines. References: <561AB49A.4060801@eastlink.ca> <20151011210902.566de251@ntlworld.com> <561AEB2F.8030808@eastlink.ca> <20151012103455.5f6159d7@pwslap01u.europe.root.pri> <561BD55C.3080006@eastlink.ca> <561BE8DC.7060506@eastlink.ca> <151012192908.ZM15508@torch.brasslantern.com> <561C717A.1030202@eastlink.ca> <151012220313.ZM16595@torch.brasslantern.com> <561C95A9.7020508@eastlink.ca> <151013125819.ZM30782@torch.brasslantern.com> <561D7AB4.7030206@eastlink.ca> <151013172339.ZM30911@torch.brasslantern.com> In-reply-to: <151013172339.ZM30911@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit 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.