Clipboard copy fails inside tmux over SSH because Posting uses pyperclip directly
Bug Description
Clipboard copy in Posting fails when Posting is running inside tmux over SSH.
Posting displays
"Clipboard error
Pyperclip could not find a copy/paste mechanism for your system.
On Linux, you can run: sudo apt-get install xclip sudo apt-get install xselect sudo apt-get install wl-clipboard"
Environment
- Posting: 2.10.0
- Textual: 6.1.0
- OS: Linux
- Terminal: Windows Terminal
- Connection: SSH
- Multiplexer: tmux
- DISPLAY: unset
- WAYLAND_DISPLAY: unset
Steps to Reproduce
- Connect to a Linux host over SSH.
- Start tmux.
- Start Posting inside tmux.
- Select text in a TextArea.
- Press y or c to copy.
- Try to paste the text into the local terminal or another application.
Actual Behavior
Posting shows a PyperclipException because pyperclip cannot find an X11 or Wayland clipboard backend.
The copy action in posting/widgets/text_area.py calls
python import pyperclip pyperclip.copy(text_to_copy)
This bypasses Textual's OSC 52 clipboard support.
Expected Behavior
When Posting runs inside tmux over SSH, copying should use a terminal clipboard mechanism such as OSC 52, instead of requiring xclip, xsel, or wl-copy on the remote host.
Additional Information
The terminal supports OSC 52, and tmux copy-mode works correctly with OSC 52.
The issue is specific to Posting's copy action, because it calls pyperclip directly.
A possible fix would be to use Textual's clipboard API when running inside tmux
for example:
python if os.environ.get("TMUX"): self.app.copy_to_clipboard(text_to_copy) else: pyperclip.copy(text_to_copy)
For nested tmux, the OSC 52 sequence may also need to be wrapped using tmux DCS passthrough.
Source: darrenburns/posting