The OSC 52 fallback sent any amount of data to the terminal, so copying a
large file (e.g. `copyfile` on a log) could be silently dropped or stall the
terminal. Fail with an error instead when the base64 payload is over 100000
bytes, so people know the copy didn't happen.
Follow-up to #14251.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OSC 52 makes the terminal emulator set the clipboard of the machine the
user is connected from, which is the only way to copy to it when running
over SSH or inside a container with no access to the local display
server.
Use it when no other clipboard tool is available, or when
ZSH_CLIPBOARD_OSC52 is set to "always"; set it to "never" to disable the
fallback. OSC 52 is write-only in practice, so clippaste keeps failing
unless a real clipboard tool is available.
Closes#13459
Previously, OS detection would happen on each invocation. This makes it
happen once (unless it fails, in which case it will try again on the
next invocation).
This has the additional benefit of localizing the platform-specific
checks and commands, too, versus spreading them out in separate
functions.
Ideally the parameter would just be removed-users could always
just do "clipcopy < some-file". but removing the parameter would break
backwards compatibility.
In any case, this simplifies the logic considerably.