Emacs command to cut OR copy to system clipboard

clipboardcopy/pastecutemacskeyboard shortcuts

As a very new Emacs user, I've been using Ctrl+w and Ctrl+y to cut/copy and paste between buffers in Emacs. Is there a way to do the same thing so that not just Emacs, but the entire system, can have access to what I am copying and pasting? Thanks.

P.S. I would like to do this in Linux (in a terminal emulator running under X) and Mac OS X (e.g. with Terminal).

Best Answer

On Linux, you can use xclip.el (https://www.emacswiki.org/emacs/xclip.el) to link the kill-ring to the clipboard from Emacs running in terminal (without losing the multiple-kill and yank capability).

To install: M-x package-install RET xclip RET. To use, just add (xclip-mode 1) to your ~/.emacs.


This didn't exist on Mac, so I modified xclip.el to work with the OSX pbcopy and pbpaste utilities. The result, pbcopy.el, is available here: https://gist.github.com/1023272

Related Question