Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I copy paste from EMACS [terminal mode] to another application without MOUSE?

Tags:

emacs

I use GNU Emacs 25.1.1. I use it in terminal mode. In GUI Mode I know how to copy and yank. In terminal mode, copying and pasting from another application works but not the usual keybinding.

Usually C-y is for yank inside emacs but in my terminal mode C-Shift-V only works for yanking.

But when I try to copy from emacs to another shell or application it doesn't copy.

I don't want to use mouse for copying and yanking.. Is there any workaround? What Am I doing Wrong?

like image 454
alamin Avatar asked Sep 07 '17 08:09

alamin


3 Answers

In "terminal mode", you're not really interacting with emacs. You're interacting with your terminal or terminal emulator.

When you copy and paste text, the terminal does it : you're taking the text that the terminal displays and not the text that is in your emacs app.

That's why you have to use terminal keybindings : Ctrl-Shift-C and Ctrl-Shift-V to copy and paste text.

That's also why pasting large text through terminal in emacs is slow : the terminal "get" the text and "redirect" it to emacs.

So, if you want to select, copy and paste text without the mouse, you'll have to configure your terminal.

Here's an example

like image 50
boehm_s Avatar answered Sep 20 '22 06:09

boehm_s


You might like to try xclip-mode (available from GNU ELPA), which relies on externals programs (xclip under X11, and pbcopy on macOS) to let Emacs communicate with your GUI (for things like C-y and C-k) even though it's running inside a text terminal.

like image 37
Stefan Avatar answered Sep 20 '22 06:09

Stefan


I do this by using shell-command-on-region along with the command-line pbpaste/pbcopy on my macOS box. Bind it to a key if necessary:

(global-set-key "\C-cr" (shell-command-on-region (point) (mark) "pbcopy"))

There are similar command-line programs you can use for Windows (https://github.com/ghuntley/pasteboard) and Linux (xsel/xclip).

like image 21
Allen Luce Avatar answered Sep 20 '22 06:09

Allen Luce