Skip to content

Instantly share code, notes, and snippets.

@abicky
Created August 29, 2012 18:00
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 abicky/3516310 to your computer and use it in GitHub Desktop.
Save abicky/3516310 to your computer and use it in GitHub Desktop.
(setq x-select-enable-clipboard t)
(defun copy-from-clipboard (text &optional rest)
(let ((process-connection-type nil) proc)
(if (eq system-type 'darwin)
(setq proc (start-process "pbcopy" "*Messages*" "pbcopy"))
(setq proc (start-process "xsel" "*Messages*" "xsel" "-b" "-i")))
(process-send-string proc text)
(process-send-eof proc)))
(defun paste-from-clipboard ()
(if (eq system-type 'darwin)
(shell-command-to-string "pbpaste")
(shell-command-to-string "xsel -b -o")))
(when (and (getenv "DISPLAY") (not window-system))
(setq interprogram-cut-function 'copy-from-clipboard)
(setq interprogram-paste-function 'paste-from-clipboard))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment