From dd7c5d1d244df73e4e92ef13509011fb9606a467 Mon Sep 17 00:00:00 2001 From: Jan Stranik Date: Wed, 29 Jul 2026 10:22:51 -0400 Subject: [PATCH] Fix copy operation on emacs runnign under TMUX upon reconnection When emacs runs under tmux, emacs copy function uses the SSH_TTY env variable to determine tty to write OCS52 codes to. when tmux disconnects and later reconnects a new tty is allocated for the terminal. That is not reflected in teh SSH_TTY and therefore copy operations on reconnected sessions starts failing. This change makes emacs detects tmux being used as a terminal. Then the variable SSH_TTY is ignored and the default tty is used. copy operations will work on reconnect. --- clipetty.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clipetty.el b/clipetty.el index cb24eec..fd76568 100644 --- a/clipetty.el +++ b/clipetty.el @@ -139,7 +139,7 @@ Optionally base64 encode it first if you specify non-nil for ENCODE." "Emit STRING, optionally wrapped in a DCS, to an appropriate tty." (let ((tmux (getenv "TMUX" (selected-frame))) (term (getenv "TERM" (selected-frame))) - (ssh-tty (getenv "SSH_TTY" (selected-frame)))) + (ssh-tty (if (getenv "TMUX" (selected-frame)) nil (getenv "SSH_TTY" (selected-frame))))) ; under TMUX SSH_TTY can get stale on reconnect (if (<= (length string) clipetty--max-cut) (write-region (clipetty--dcs-wrap string tmux term ssh-tty)