Skip to content

Instantly share code, notes, and snippets.

@ochko
Created October 20, 2011 11:52
Show Gist options
  • Save ochko/1300960 to your computer and use it in GitHub Desktop.
Save ochko/1300960 to your computer and use it in GitHub Desktop.
It saves last item in emacs kill ring into clipboard
(defun copy-clipboard()
"Save last item in kill ring to clipboard"
(interactive)
(let ((tmp-file (make-temp-file "pbcopy")))
(with-temp-buffer
(yank)
(when (file-writable-p tmp-file)
(write-region (point-min)
(point-max)
tmp-file)
(shell-command (concat "cat " tmp-file " | pbcopy")))
(message "Selection is saved to clipboard"))))
(global-set-key (kbd "C-c C-c") 'copy-clipboard)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment