7

When I scroll in a pane, my current shell prompt is not on the screen anymore, then I select anything (for example when I am explaining to a colleague something, just to point a line), the result will be that, when I release a mouse button after selection, the scrolling position will be reseted to the bottom of the output. So basically you cannot select anything multiple times in one scrolling position if you are not at the bottom of your output. That is pretty unpleasant, can I fix that?

1

3 Answers 3

3

I recently had to update my ~/.tmux.conf because of this issue.

See this answer or this github issue for more context, but the essential part that helped in my case was this line:

unbind -T copy-mode MouseDragEnd1Pane

NOTE: This fixes the issue where selecting jumps the focus back to the bottom, but introduces a new issue: selecting and then scrolling results in the selection moving with the scroll position, so if I just wanted to select a single word or line, and then scroll somewhere else, the selection grows.

I'll update this answer if I find a workaround to the second issue.

0

I'm on Debian 9 and my tmux is in the version 2.3-4.

It's about these default bindings:

bind-key -t vi-copy    MouseDragEnd1Pane copy-selection
bind-key -t emacs-copy MouseDragEnd1Pane copy-selection

It depends on mode-keys option (vi/emacs), which one applies in any single case. It doesn't matter, we will fix them both anyway.

copy-selection is not well documented in the manual, however one example uses copy-selection -x without explanation what -x means. I tried it and it seems it solves your problem. Add these lines to your ~/.tmux.conf:

bind-key -t vi-copy    MouseDragEnd1Pane copy-selection -x
bind-key -t emacs-copy MouseDragEnd1Pane copy-selection -x

Restart tmux server or source the file (prefix:source ~/.tmux.confEnter).

0

I was able to piece together a solution with the help of this answer on unix stackexchange and the tmux-yank source code.

# Only add this line if using tmux-yank
set -g @yank_with_mouse off

Replace "reattach-to-user-namespace pbcopy" with the result of clipboard_copy_command true here. (can evaluate in your head)

e.g. "cat | clip.exe" on Windows

bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "reattach-to-user-namespace pbcopy" \; send -X clear-selection
bind-key -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe "reattach-to-user-namespace pbcopy" \; send -X clear-selection

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .