mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
On a headless SSH host there is no X11 or Wayland display, so none of xclip, xsel, or wl-copy can reach a clipboard. atotto/clipboard then reports itself unsupported and every copy action fails with "No clipboard utilities available", even though installing those tools cannot help without a display server. This breaks copying branch names, commit hashes, file paths, and diffs in the common setup of developing on a remote box over SSH inside tmux. Extend CopyToClipboard and PasteFromClipboard with a built-in fallback chain that only engages when no os.copyToClipboardCmd is configured and clipboard.Unsupported is true, so any setup with a working native utility or a configured command is completely unaffected. When running inside tmux, copy via `tmux load-buffer -w -` and paste via `tmux save-buffer -`. The -w flag relays the buffer to the outer terminal's system clipboard through tmux's own OSC 52 emission (with `set-clipboard on`), and because the tmux buffer is readable this gives real bidirectional clipboard support within the session, including paste. Without tmux, emit an OSC 52 escape sequence to the controlling terminal, so terminals that support it still receive the copy. OSC 52 read-back is refused by most terminals for security reasons, so paste returns the last value copied in-session, matching how Neovim's and Helix's clipboard providers behave. The sequence framing is factored into a pure buildOSC52Sequence so it can be verified without touching the terminal. Failing both, fall through to the native atotto path unchanged. Fixes #5724 |
||
|---|---|---|
| .. | ||
| app | ||
| cheatsheet | ||
| commands | ||
| common | ||
| config | ||
| constants | ||
| env | ||
| fakes | ||
| gocui | ||
| gui | ||
| i18n | ||
| integration | ||
| jsonschema | ||
| logs | ||
| snake | ||
| tasks | ||
| theme | ||
| updates | ||
| utils | ||