> In summary: multiplexers add unnecessary overhead, suffer from a complexity cascade, because they actually have to translate escape codes, modifying them in hackish ways to get them to work with their concepts of windows/sessions.
What does that have to do with you using tmux? You're not the one maintaining tmux's codebase.
This problem is in no way unique to tmux. You have the same problem with any terminal app that takes over drawing, eg vim. That said it is also easy enough to fix.
The solution is OSC52, a terminal escape sequence that the emulator can use to interact with the system clipboard (kitty, alacritty, iterm2 all support this). The first step is to get you a script that writes out data in that protocol. Its easy enough:
#!/usr/bin/env python3
import os, base64, sys
clip = base64.b64encode(sys.stdin.buffer.read())
for pid in (os.getpid(), os.getppid()): # so that osc52-copy can be invoked by processes that themselves do not have a tty.
cty = f"/proc/{pid}/fd/1"
try:
fd = os.open(cty, os.O_WRONLY)
if os.isatty(fd):
os.write(fd, b'\x1b]52;c;') # the actual escape sequence
os.write(fd, clip)
os.write(fd, b'\a')
break
except:
continue
finally:
os.close(fd)
else:
raise SystemExit(f"no tty")
Now you can do this:$ grep my_thing < some.txt | osc52-copy
And whatever got into osc52 is now on your system clipboard.
Tmux (set -g clipboard on) and nvim (unset clipboard) both have native osc52 support, and the script above can be used to integrate other places.
In sane units: 3.8 kW
5.1 Horsepower