From b74c7151643f6b06b5c130b27ab755e57baa1543 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Mon, 26 Oct 2026 13:29:09 +0100 Subject: [PATCH] pinwheel: Copy to clipboard via OSC 52 in Emacs so it works over SSH --- hosts/pinwheel/modules/emacs/config.org | 19 +++++++++++++++++-- hosts/pinwheel/modules/tmux/default.nix | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hosts/pinwheel/modules/emacs/config.org b/hosts/pinwheel/modules/emacs/config.org index 343372f..60cb376 100644 --- a/hosts/pinwheel/modules/emacs/config.org +++ b/hosts/pinwheel/modules/emacs/config.org @@ -86,8 +86,24 @@ * Setup #+BEGIN_SRC emacs-lisp #+END_SRC -** Use wl-clipboard for interprocess copy/paste +** Use wl-clipboard and OSC 52 for interprocess copy/paste #+BEGIN_SRC emacs-lisp + (setq kill-do-not-save-duplicates t) + + (defun alex/osc52-copy (text) + (unless (display-graphic-p) + (send-string-to-terminal + (concat "\e]52;c;" + (base64-encode-string (encode-coding-string text 'utf-8) t) + "\a")))) + + (defun alex/clipboard-copy (text) + (alex/osc52-copy text) + (when (fboundp 'wl-copy) + (wl-copy text))) + + (setq interprogram-cut-function 'alex/clipboard-copy) + (setq wl-copy-process nil) (when (string-prefix-p "wayland" (getenv "WAYLAND_DISPLAY")) (defun wl-copy (text) @@ -103,7 +119,6 @@ nil ; should return nil if we're the current paste owner (shell-command-to-string "wl-paste -n | tr -d \r"))) - (setq interprogram-cut-function 'wl-copy) (setq interprogram-paste-function 'wl-paste)) #+END_SRC ** Don't create backup files, don't create #autosave# files diff --git a/hosts/pinwheel/modules/tmux/default.nix b/hosts/pinwheel/modules/tmux/default.nix index 9bf846e..e636d9f 100644 --- a/hosts/pinwheel/modules/tmux/default.nix +++ b/hosts/pinwheel/modules/tmux/default.nix @@ -23,6 +23,8 @@ set-option -g allow-rename off + set -g set-clipboard on + # Status line colors set -g status-fg '#${config.lib.colors.foreground}' set -g status-bg '#${config.lib.colors.background}'