Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: subsitutions and beginning of lines.

On Oct 12, 10:07am, Ray Andrews wrote:
} ... 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
} So, the 'eval'ed expression ends up like:
} 'history -100 | grep --color=always to | grep --color=always 'a date' | ... '

If you're using "grep" to do the colorizing, there's no point in using
the $history variable to get the history entries, because you need them
to end up on stdout for passing through grep anyway.

(Generic advice to anyone reading this:  Asking about one small piece of
a larger problem is quite likely to get you an inappropriate solution.
Context is important.)

} the outputno longer lines up because double spaces become single
} spaces whereas double spaces are needed for the brutal ' //#???????/'
} substitution to work properly.

Why not simply use "history -n" so the numbers are omitted in the first
place?  Then you don't need to assign to var=(...) and apply //#.../.
That whole chunk of code just reduces to

    eval history -n $nnumber $sstring

and you're done.

Messages sorted by: Reverse Date, Date, Thread, Author