NHDaly / tmux-better-mouse-mode

A tmux plugin to better manage and configure the mouse.
MIT License
916 stars 27 forks source link

How do I make it act as cmd's quickedit mode ? #35

Closed eromoe closed 7 years ago

eromoe commented 7 years ago

Now, I need shift + left click to copy, shift + right click to paste. How do I change to

Quickedit mode in Windows cmd:

  1. make selection in terminal using the cursor
  2. copy by right click selection
  3. paste by right click

or just:

  1. make selection by cursor and copy that when left click mouse up.
  2. paste by right click
NHDaly commented 7 years ago

Totally.

Let's do the shift + right click first since it's easier:

tmux bind-key -Troot S-MouseDown3Pane select-pane -t = \\\; paste-buffer -t =

Run that from a terminal and it should just work! :) This SO answer has a good explanation of the \\\;.

If you want to put this in your ~/.tmux.conf so it runs every time you restart tmux, drop the word tmux at the front and change \\\; to \;:

bind-key -Troot S-MouseDown3Pane select-pane -t = \; paste-buffer -t =

shift + left click to copy is harder... Left-click drag and release is already set to do copy so maybe you don't need to change it? I present here what I think should work, but it doesn't seem to work correctly for me. It's possible that shift+drag is not actually implemented well in tmux. Maybe ask on StackOverflow/SuperUser? Or you could try asking on an issue on tmux directly?

That said, here's what I tried. It seems like it should work, but tmux seems to have trouble with S-MouseDrag1Pane and S-MouseDragEnd1Pane.

You can unbind the default left-click-drag-to-copy via the following:

tmux unbind -T root MouseDrag1Pane;
tmux unbind -T copy-mode MouseDrag1Pane;
tmux unbind -T copy-mode MouseDragEnd1Pane;

Then rebind those commands to shift left click with the following (note the S- -- that's what adds the shift modifier):

tmux bind-key -T root S-MouseDrag1Pane   if-shell -F -t = "#{mouse_any_flag}" "if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"" "copy-mode -M"
tmux bind-key -T copy-mode S-MouseDrag1Pane    select-pane \\\; send-keys -X begin-selection
tmux bind-key -T copy-mode S-MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
NHDaly commented 7 years ago

Good luck! :) Either way, i'm going to close this Issue for now, since it's not an issue with this plugin.

Feel free to reopen if you need to. (i'll keep getting notifications if you respond on the closed issue.)