From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29892 invoked by alias); 12 Oct 2015 17:07:46 -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: 20745 Received: (qmail 25837 invoked from network); 12 Oct 2015 17:07:43 -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=T/C1EZ6Q c=1 sm=1 tr=0 a=TDXRqai3AtB4qfuLBL55xA==:117 a=TDXRqai3AtB4qfuLBL55xA==:17 a=N659UExz7-8A:10 a=x7ZrRyPeok4CLjzP-2QA:9 a=pILNOxqGKmIA:10 Message-id: <561BE8DC.7060506@eastlink.ca> Date: Mon, 12 Oct 2015 10:07:40 -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> In-reply-to: <561BD55C.3080006@eastlink.ca> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit Peter, A few niggles with the substitution thing: $ history -10 85* s h okIFS 12586* freshensource 12587* cp Navtools/navtools Source 12588zsh 12589 echo "Shall I compare thee to a Summer's day?" 12590* echo "Thou art more lovely and more temperate" 12591 echo "Rough winds do shake the darling buds of May" 12592* echo And Summer's lease hath all to short a date" 12593* history -10 ... it all lines up like North Korean soldiers. ('85' is of course ancient, but it would line uptoo if it was in the output.) So, my 'h' wrapper is an incremental colorized 'grep' of history output: $ echo "Shall I compare thee to a Summer's day?" $ echo "Thou art more lovely and more temperate" $ echo "Rough winds do shake the darling buds of May" $ echo "And Summer's lease hath all to short a date" $ h 100 to print -r - $history[-5,-1] print -lr - $history[-5,-1] print -l - $history[-5,-1] print -l - $history[-1] print -r $history[-1] cp Navtools/navtools Source echo "Shall I compare thee to a Summer's day?" echo And Summer's lease hath all to short a date $ h 100 to 'a date' echo And Summer's lease hath all to short a date ** ****** ... Each search parameter is colorized incrementally. (I add the minus sign automatically) It now strips off the leading stuff as we've discussed. Code as I have it now is: OLDIFS=$IFS IFS=$'\n' var=($(eval history $nnumber $sstring)) echo "${(F)var[@]//#???????/}" IFS=$OLDIFS ... where $nnumber is obvious and $sstring is put together like this: while [ -n "$1" ]; do sstring="$sstring | grep '$1'" shift done So, the 'eval'ed expression ends up like: 'history -100 | grep --color=always to | grep --color=always 'a date' | ... ' (Pardon the long lead-up) So ... the issue is that if I use your method it's much simpler *but* when the splittings and joinings and all the rest of that invisible stuff happens the outputno longer lines up because double spaces become single spaces whereas double spaces are needed for the brutal ' //#???????/' substitution to work properly. Is there an elegant solution? My code is obviously cumbersome.A more refined substitution could fix it, but on principal I want to leave doublespaces alone without needing to play with $IFS.All this splitting stuff is wonderful when it works, but there are times when I wish I could turn it all off.