Skip to content

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
yank.tmux Outdated
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"

Copy link
Author

Choose a reason for hiding this comment

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

updated! thanks for the suggestion

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