-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I'm currently working on a small script between tmux and iTerm2 for myself for clipboard integration.
I've worked out that it'd in theory be possible to combine tmux's tmux;
passthrough and iTerm2's 1337;CopyToClipboard=
escape sequence(1) to do a direct copy from the remote terminal to the local clipboard. I even have a script that somewhat works: https://gist.github.com/cesarkawakami/81a567af45a16522cb7ee20642feed41
The script emits something like this [newlines added for clarity]:
\033Ptmux;\033
\033\033]1337;CopyToClipboard=\007
<whatever>
\033\033]1337;EndCopy\007
\033\\
The problem I'm having is that the passthrough sequence has an upper bound on the number of characters that are passed through. If I'm emitting
\033Ptmux;\033<whatever>\033\\
and <whatever>
is larger than (apparently) 211 characters, the command simply doesn't go through.
I've thought about chunking the input, doing something like:
\033Ptmux;\033
\033\033]1337;CopyToClipboard=\007
first_chunk
\033\\
\033Ptmux;\033
second_chunk
\033\033]1337;EndCopy\007
\033\\
But as soon as I emit the first \033\\
, tmux emits some escape codes itself, adding spurious characters (from what I can see, they're always \033[1;1H
) to the local clipboard.
Is there a way to either (1) avoid emitting these control characters temporariliy or (2) somehow work around the passthrough length limitation?