Douglas Su
Douglas Su

Reputation: 3364

How to copy text to system clipboard in emacs while working in terminal buffer?

I usually use emacs in a text terminal environment to manipulate text. In some particular situations, however, I want to interact with the system's clipboard, for example, copy text from emacs to a website. Is it possible to yank text to the system's clipboard directly from or to emacs? How?

Upvotes: 3

Views: 4086

Answers (2)

Stefan
Stefan

Reputation: 28591

There's support for doing just that in Emacs-25 (see the NEWS file, looking for xterm-extra-capabilities), tho it depends on your terminal emulator providing corresponding support, which is apparently usually disabled by default, so you additionally need to configure your termninal emulator as well.

Another option is to install the xclip package, which is available on GNU ELPA.

Upvotes: 2

Chillar Anand
Chillar Anand

Reputation: 29594

Terminal in emacs is nothing but a buffer. If you are running terminal using eshell, you can directly copy to clipboard using M-w like you do in normal buffer.

If you are running terminal using ansi-term, yanking/copying is little tricky. You need to go to term-line-mode using C-c C-j copy whatever you want and come back to term-char-mode using C-c C-k. See this answer for more info.

Upvotes: 3

Related Questions