Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] From tmux within SSH session, clipetty-kill-ring-save does not send to system clipboard #30

Open
jokem59 opened this issue Feb 18, 2024 · 2 comments
Assignees

Comments

@jokem59
Copy link

jokem59 commented Feb 18, 2024

Describe the bug
When I SSH onto my Amazon Linux instance. If I open terminal emacs WITHOUT a tmux session, clipetty-kill-ring-save works as intended and sends the region to my system clipboard.

From that same SSH session, if I launch tmux and open terminal emacs, clipetty-kill-ring-save does not send anything to the system clipboard. I don't see anything in the *Messages* buffer that indicates any error. toggle-debug-on-error also doesn't trip anything.

This was working prior and I'm unsure what changed (no changes to tmux/emacs configs recently).

To Reproduce
From Ubuntu 20.04 ssh to an Amazon Linux 2 instance. Launch tmux from this ssh session and launch emacs. Attempt clipetty-kill-ring-save and observe the contents are not present in the system clipboard.

Expected behavior
I expect the region clipetty-kill-ring-save is called on to be available on the system clipboard.

** System Info (please complete the following information):**

  • OS: Ubuntu 20.04.6 LTS, 5.15.0-92-generic
  • Emacs Version: 27.2
  • Terminal program: st
  • Any terminal multiplexers in play: tmux 3.3a
  • Local or remote (over SSH): Remote

Additional context
N/A

@SteVwonder
Copy link

SteVwonder commented Jun 17, 2024

I had the same issue. Walking through the code, my issue turned out to be due to TMUX, TERM, and SSH_TTY env vars returning as nil from the call to (getenv "<ENVVAR>" (selected-frame)). Dropping the (selected-frame) bit makes things work again:

diff --git a/clipetty.el b/clipetty.el
index cb24eec..fc609a3 100644
--- a/clipetty.el
+++ b/clipetty.el
@@ -137,9 +137,9 @@ Optionally base64 encode it first if you specify non-nil for ENCODE."
 
 (defun clipetty--emit (string)
   "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))))
+  (let ((tmux    (getenv "TMUX"))
+        (term    (getenv "TERM"))
+        (ssh-tty (getenv "SSH_TTY")))
     (if (<= (length string) clipetty--max-cut)
         (write-region
          (clipetty--dcs-wrap string tmux term ssh-tty)

I don't think this is a general solution that can be submitted as a PR since respecting the environment of each frame seems reasonable. But it is at least a temporary workaround. I'm not sure why that getenv is failing when targeting a specific frame. And I'm not sure why it works outside of tmux.

SteVwonder pushed a commit to SteVwonder/clipetty that referenced this issue Jun 17, 2024
@yashaswikarnati
Copy link

I could not get it to work in a tmux session. I ssh into my ubuntu machine from my mac, start tmux session and run emacs (spacemacs). (getenv "TMUX" (selected-frame) returns me a valid value - /tmp/tmux-361936330/default,49641,0.

It works outside of tmux

tmux version - 3.4
spacemacs version - 0.999.0@29.3
iterm2 mac terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants