Skip to content

yank on double click and triple click #175

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NgoKimPhu
Copy link

trigger yank action on mouse double click and triple click, both in copy-mode and in root mode

@NgoKimPhu NgoKimPhu force-pushed the double-triple-click branch from 345c399 to 76645fe Compare December 6, 2023 08:42
@NgoKimPhu NgoKimPhu force-pushed the double-triple-click branch from 76645fe to 50c72e5 Compare December 6, 2023 08:43
if [[ "$(yank_with_mouse)" == "on" ]]; then
tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
tmux bind-key -T copy-mode-vi DoubleClick1Pane "select-pane ; send-keys -X select-word ; run-shell -d 0.3 ; send-keys -X \"$(yank_action)\" \"$copy_command_mouse\""
Copy link

@x3rAx x3rAx Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR, I was about to do the same :)

However, could you please change this to:

Suggested change
tmux bind-key -T copy-mode-vi DoubleClick1Pane "select-pane ; send-keys -X select-word ; run-shell -d 0.3 ; send-keys -X \"$(yank_action)\" \"$copy_command_mouse\""
tmux bind-key -T copy-mode-vi SecondClick1Pane "select-pane ; send-keys -X select-word"
tmux bind-key -T copy-mode-vi DoubleClick1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"

Doing so should remove the need for the delayed run-shell. It also highlights the word immediately after the double click and does not wait if a triple click is triggered but copies only when no triple click occurs.

I haven't tested this here but I have something similar in my config:

# Double LMB select word in copy mode
#
# The `SecondClick1Pane` event is fired for the second click even if there
# is a `TripleClick1Pane` key binding.
bind-key -T copy-mode-vi SecondClick1Pane \
    select-pane \; \
    send-keys -X select-word
bind-key -T copy-mode-vi DoubleClick1Pane \
    send-keys -X copy-pipe-no-clear "xclip -in -sel primary"

# Triple LMB Select Line in copy mode
bind-key -T copy-mode-vi TripleClick1Pane \
    select-pane \; \
    send-keys -X select-line \; \
    send-keys -X copy-pipe-no-clear "xclip -in -sel primary"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants