试试 clipetty 这个包
;; 远程ssh中emacs copy的内容放到系统剪切板
;; mac下不需要tmux配合其他配置
;; https://github.com/spudlyo/clipetty
(use-package clipetty
:ensure
:hook (after-init . global-clipetty-mode)
)
;; 解决问题:macos在本地tmux中的emacs,copy的内容无法放到系统剪切板
;; 需要支持: brew install reattach-to-user-namespace
(when (eq system-type 'darwin)
(defun copy-from-osx ()
"Use OSX clipboard to paste."
(shell-command-to-string "reattach-to-user-namespace pbpaste"))
(defun paste-to-osx (text &optional push)
"Add kill ring entries (TEXT) to OSX clipboard. PUSH."
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "reattach-to-user-namespace" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx))