Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bracketed paste - chopping trailing newlines
Reordering things a bit for response ...
On Aug 29, 3:24am, Carsten Hey wrote:
}
} The other natural choice to enable distinguishing a running command from
} a paste is using zle_highlight. This could also avoid the need for the
} possibly unexpected newline stripping feature.
}
} An alternative to paste:standout is paste:underline. Given that this
} one does not suffer from similar possible problems as paste:standout,
Hm, standout, boldface, and underline are all used already for different
defaults. Underline is for isearch, though, so I suppose it's quite
unlikely to clash with paste highlighting.
} [...] I think, that a trailing newline should only
} be stripped if it does not immediately follow an other newline
Another way to approach this would be for a trailing newline to actually
be taken as accept-line, provided that RBUFFER is empty. This would be
the least different from previous (unbracketed) paste behavior, and
could be independent of the number of trailing newlines. In contexts
other than PS1, e.g., a here-document, this is identical to keeping
the trailing newline (except that the PS2 prompt is repeated).
Here's a way to try that on for size:
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
nl-accept () {
if [[ "$PASTED" = *$'\n' && -z "$RBUFFER" ]]
then
PASTED="${PASTED%?}"
zle -U $'\n'
fi
return 0
}
zstyle :bracketed-paste-magic active-widgets ''
zstyle :bracketed-paste-magic paste-finish nl-accept
Messages sorted by:
Reverse Date,
Date,
Thread,
Author