Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send region to the clipboard via the xterm clipboard integration (PASTE64/OSC52)
(defun send-region-to-clipboard (START END)
;; Place https://github.com/skaji/remote-pbcopy-iterm2/blob/master/pbcopy as `cpbcopy`
(interactive "r")
(let ((infile (make-temp-file "send-region-to-clipboard")))
(write-region (buffer-substring (region-beginning) (region-end))
nil
infile
nil
'nomsg)
(with-temp-buffer
(call-process "cpbcopy" infile t)
(send-string-to-terminal (buffer-substring-no-properties
(point-min) (point-max))))
(delete-file infile)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.