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

Re: zle_highlight and yank

Yuri D'Elia wrote on Tue, Dec 08, 2015 at 22:37:36 +0100:
> On 08/12/15 22:28, Mikael Magnusson wrote:
> >> I would have expected it to respect the paste: style.
> >>
> >> Or maybe it's a good idea that it doesn't, to differentiate between a
> >> terminal paste and a regular one. But then again, I'd like a yank: style
> >> in there.
> > 
> > I guess it's a bug that (none) doesn't disable the paste: style, but
> > you can explicitly put in paste: to disable it if you want, eg
> > zle_highlight=(none paste:)
> I really only wanted to disable yank highlighting, which I find
> distracting since I often know exactly what I just previously cut.
> But I do find highlighting for paste generally useful on the other hand.

Try this:

    f() {
      zle .$WIDGET "$@"
      integer start end
      if (( YANK_START > YANK_END )); then
        start=$YANK_END end=$YANK_START
        end=$YANK_END start=$YANK_START
      region_highlight+=("$start $end bg=blue")
      zle -f 'yank'
    zle -N yank f

You will want to change 'bg=blue' to whatever your default colors are;
for some reason specifying "none" doesn't override the 'standout'

"zle -f" was added in zsh-5.2, for older versions just comment it out.



P.S. It'd be nice to have built-in min() and max() math functions..

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