Skip to content

Instantly share code, notes, and snippets.

@ElectricCoffee
Forked from rand00/gist:e8a382e3aa1b64a53727
Last active August 29, 2015 14:07
Show Gist options
  • Save ElectricCoffee/9387e27397a70e1a6d4d to your computer and use it in GitHub Desktop.
Save ElectricCoffee/9387e27397a70e1a6d4d to your computer and use it in GitHub Desktop.
OSX Version of rand00's copy function
(defun copy-to-clipboard ()
(interactive)
(if (region-active-p)
(progn (shell-command-on-region
(region-beginning) (region-end)
"pbcopy")
(message "Copied region to clipboard!")
(deactivate-mark))
(message "No mark set.")))
;; optional
(defun copy-whole-buffer-to-clipboard ()
(interactive)
(mark-whole-buffer)
(copy-to-clipboard))
(global-set-key (kbd "C-c c") 'copy-to-clipboard)
(global-set-key (kbd "C-c M-c") 'copy-whole-buffer-to-clipboard)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment