3

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?

Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
Douglas Su
  • 3,214
  • 7
  • 29
  • 58

2 Answers2

3

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.

Community
  • 1
  • 1
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
2

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.

Stefan
  • 27,908
  • 4
  • 53
  • 82