Skip to content

Instantly share code, notes, and snippets.

@carimatics
Last active June 7, 2016 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carimatics/f2d0a24aa4000036131d1fffc0d42b5e to your computer and use it in GitHub Desktop.
Save carimatics/f2d0a24aa4000036131d1fffc0d42b5e to your computer and use it in GitHub Desktop.
pbcopy & pbpaste for Emacs
;;; Share the clipboard between OS X and Emacs
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment