From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: subsitutions and beginning of lines.
Date: Mon, 12 Oct 2015 10:07:40 -0700 [thread overview]
Message-ID: <561BE8DC.7060506@eastlink.ca> (raw)
In-Reply-To: <561BD55C.3080006@eastlink.ca>
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.
next prev parent reply other threads:[~2015-10-12 17:07 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 [this message]
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
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=561BE8DC.7060506@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).