2

My host machine is Windows, but I'm working in Linux virtualbox machine over ssh from mintty in MSYS2 environment. As you may know, in mintty you copy via C-insert and paste via C-S-insert. When I ssh from mintty to my linux guest and open in it Emacs (emacs-nox) I can paste with default shortcut for mintty, it triggers Emacs function xterm-paste. My problem is that I can not find way to copy, there's no xterm-copy function at all. Also there's no X so I can not use xsel as I used before.

So my question is how to copy to mintty clipboard from terminal emacs, is there any way? I always had problems with all those clipboard possibilities and can not figure it out.

4
  • if you run Emacs ≥22 with X support compiled in, you can simply use Emacs's default methods to copy into (M-w) and paste from (C-y) the clipboard, in the same manner as you do when working inside Emacs.
    – user17303
    Oct 28, 2017 at 22:10
  • I dont have X, I'm running headless linux vm. Or you meant install Emacs (not emacs nox) just run it with nw option?
    – sandric
    Oct 28, 2017 at 22:50
  • it does not matter whether you run it with or without -nw, it cannot use X on the windows side anyways unless you install Cygwin/X or the like. But it has to be a version with X11 enabled, not emacs-nox. Only the X11 part gives the ability to cut'n'paste from/to a GUI terminal (xterm, mintty etc.)
    – user17303
    Oct 28, 2017 at 22:55
  • the „to a GUI terminal” above should have read „X clipboard” for clarity. Sorry.
    – user17303
    Oct 29, 2017 at 14:06

1 Answer 1

1

I have pretty similar settings as you do running emacs-nox on linux over SSH from a windows host with mintty.

With the default settings, you can try holding shift and dragging the mouse over the region you want to copy and it will automatically copy to system clipboard. Some settings to verify that this will work as I described is to check mintty options:

  • Options->Mouse->Copy on select is checked.
  • Options->Mouse->Default click target: Application
  • Options->Mouse->Modifier for overriding default: Shift

You can make this even easier by changing the default click target to Window meaning you can just drag the text you want to copy. This has some annoyances such as requiring me to toggle off line numbers and close other windows but it's the best solution I have found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.