Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lua functions to check mouse selection and copy it somewhere #1252

Closed
bew opened this issue Oct 23, 2021 · 2 comments
Closed

Add lua functions to check mouse selection and copy it somewhere #1252

bew opened this issue Oct 23, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@bew
Copy link
Contributor

bew commented Oct 23, 2021

Is your feature request related to a problem? Please describe.
For me, when on Linux (X11), mouse selection copy to clipboard in wezterm is always done with a keybind: Ctrl-Shift-c

But it is always hard to reach, and using it often (because firefox doesn't understand primary selection) is cumbersome, and I don't want to permanently use my precious Alt-c key (very easy to reach!) that I use for copy in all my terminal programs.

Describe the solution you'd like

I want to be able to bind Alt-c to copy mouse selection to clipboard, ONLY when there is an active mouse selection, otherwise send Alt-c to the terminal program.

Needed functions:

  • has_mouse_selection() (returns bool)
  • get_mouse_selection() (returns string or nil)
  • copy_to(destination)

Describe alternatives you've considered
Waiting... but that doesn't work ^^

Or keep using Ctrl-Shift-c keybind, but it's always hard to reach...

@bew bew added the enhancement New feature or request label Oct 23, 2021
@bew
Copy link
Contributor Author

bew commented Dec 5, 2021

I missed / forgot about #575, which added a function to get current selection!
combined with the SendKey action, here is the working keybinding:

  {mods="ALT", key="c", action=wezterm.action_callback(function(win, pane)
    local has_selection = win:get_selection_text_for_pane(pane) ~= ""
    if has_selection then
      win:perform_action({CopyTo="ClipboardAndPrimarySelection"}, pane)
    else
      win:perform_action({SendKey={mods="ALT", key="c"}}, pane)
    end
  end)},

@bew bew closed this as completed Dec 5, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant