wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.78k stars 751 forks source link

clarify mouse-based copy/selection behavior #722

Open dsoprea opened 3 years ago

dsoprea commented 3 years ago

I'd like just to be able to select something and have it copy. It seems like this might be supported, though searching for "copy" in the config index results in four hits, all of which are keyboard oriented. However, under the entry for "Copy Mode" (https://wezfurlong.org/wezterm/copymode.html), it implies that the mouse support is there, or maybe should even "just work" by default:

Copy mode allows you to make selections using the keyboard; no need to reach for your mouse or trackpad.

But, there's seemingly no documentation for it. So, the alternative is that I have to use a three-button shortcut, which is too heavy to be done as frequently as I need it.

bew commented 3 years ago

On which system are you? On Linux with X11, selecting with the mouse should automatically copy to the primary selection (like most other programs). And on (all?) other systems, selecting with the mouse should copy by default to the system clipboard

dsoprea commented 3 years ago

Ah, sorry. Forgot to mention that I'm on Manjaro.

On Fri, Apr 23, 2021, 07:26 Benoit de Chezelles @.***> wrote:

On which system are you? On Linux with X11, selecting with the mouse should automatically copy to the primary selection (like most other programs). And on (all?) other systems, selecting with the mouse should copy by default to the system clipboard

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wez/wezterm/issues/722#issuecomment-825593015, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFOW2QCXYNWZPOHTN5A5ADTKFKOLANCNFSM43OJNQYA .

bew commented 3 years ago

Mouse selection should "just work" by default as you say, on Manjaro I'm guessing you're on X11 not Wayland, try to select some text in wezterm and paste it in another program (or in wezterm) with Shift-Insert or a middle click (this is usually how to paste the primary selection). It should also work from another program to wezterm.

If you want to instead copy to the system clipboard (so you can paste with Ctrl-v or similar), you need to press a short cut (Ctrl-Shift-c) after you selected something in wezterm (and other programs on linux). This can be changed in wezterm, by setting a mouse binding like:

return {
  mouse_bindings = {
    -- Change the default click behavior so that it only selects/copy
    -- text and doesn't open hyperlinks.
    {
      event={Up={streak=1, button="Left"}},
      mods="NONE",
      -- complete the selection and copy it to the system clipboard
      action=wezterm.action{CompleteSelection="Clipboard"},

      -- for reference, the default action is:
      --action=wezterm.action{CompleteSelectionOrOpenLinkAtMouseCursor="PrimarySelection"},
    },
  },
}

This is derived from an example in https://wezfurlong.org/wezterm/config/mouse.html

If that doesn't work, can you please describe precisely what you're trying (key presses, mouse clicks) and what doesn't work?


@wez maybe we can have a standalone page about the clipboard in the docs, to explain the select-to-copy behavior of the mouse, and give some intel about how clipboard/primary-selection works on Linux by default (for unsuspecting people 👀), and give links to mouse/key binding pages & the various KeyAssignement that can be used around copying things