Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: subsitutions and beginning of lines.
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author