Last active
July 22, 2017 17:16
-
-
Save mecab/2ea01bf0059c40795fae2becb681d059 to your computer and use it in GitHub Desktop.
Send region to the clipboard via the xterm clipboard integration (PASTE64/OSC52)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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