简体   繁体   English

在终端缓冲区中工作时如何将文本复制到emacs中的系统剪贴板?

[英]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. 我通常在文本终端环境中使用emacs来处理文本。 In some particular situations, however, I want to interact with the system's clipboard, for example, copy text from emacs to a website. 但是,在某些特定情况下,我想与系统的剪贴板交互,例如,将文本从emacs复制到网站。 Is it possible to yank text to the system's clipboard directly from or to emacs? 是否可以直接从emacs或向emacs发送文本到系统剪贴板? How? 怎么样?

Terminal in emacs is nothing but a buffer. emacs中的终端不过是缓冲区。 If you are running terminal using eshell , you can directly copy to clipboard using Mw like you do in normal buffer. 如果您使用eshell运行终端,则可以像在普通缓冲区中一样使用Mw直接复制到剪贴板。

If you are running terminal using ansi-term , yanking/copying is little tricky. 如果您正在使用ansi-term运行终端,则拉动/复制操作并不容易。 You need to go to term-line-mode using Cc Cj copy whatever you want and come back to term-char-mode using Cc Ck . 您需要使用Cc Cj复制到term-line-mode复制任何内容,然后使用Cc Ck返回到term-char-mode See this answer for more info. 有关更多信息,请参见此答案

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. 在Emacs-25中支持执行此操作(请参阅NEWS文件,查找xterm-extra-capabilities ),这取决于您的终端仿真器是否提供相应的支持,显然默认情况下通常将其禁用,因此您还需要配置您的终端仿真器。

Another option is to install the xclip package, which is available on GNU ELPA. 另一个选择是安装xclip软件包,该软件包在GNU ELPA上可用。

This article ( http://blog.binchen.org/posts/copypaste-in-emacs.html ) helps me. 本文( http://blog.binchen.org/posts/copypaste-in-emacs.html )对我有帮助。 In it, the author implement a function to fulfil such a task. 在其中,作者实现了一项功能来完成这样的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM