tmux mouse copy-mode jumps to bottom
i was able to get mouse selection to stop jumping to the bottom in tmux (version 2.2) by adding the following to my ~/.tmux.conf
:
setw -g mouse on
setw -g mode-keys vi
unbind -t vi-copy MouseDragEnd1Pane
caveat: this has the side effect of turning on vi mode.
i found this issue to be relevant, and found the configuration above in these dotfiles.
As of tmux 2.5 you should use
unbind -T copy-mode-vi MouseDragEnd1Pane
I'd say the easiest way nowadays is to just use the tmux-yank plugin and add the yank_action configuration option:
# ~/.tmux.conf
set -g @yank_action 'copy-pipe' # or 'copy-pipe-and-cancel' for the default
Additionally, tmux-yank also manages for you the differences between OS clipboards (Linux, macOS, WSL) and adds some very useful shortcuts for copying the current command line content and cwd. Highly recommended.
The following worked for me. Thanks to @stagebind
on github!
For vi-mode config, https://github.com/tmux/tmux/issues/140#issuecomment-321144647:
unbind -T copy-mode-vi MouseDragEnd1Pane
For non vi-mode config, https://github.com/tmux/tmux/issues/140#issuecomment-302742783:
# 2.4+
unbind -T copy-mode MouseDragEnd1Pane
# 2.2 - 2.3
unbind -t vi-copy MouseDragEnd1Pane
Took me some time to get the correct answer.
I am also using Alacritty and cannot enable copy on mouse select because of an issue with MouseDragEnd1Pane
as described in: https://github.com/jwilm/alacritty/issues/1002.
Selecting the text with the mouse and then if I need copy it using the key y
works for me with this config:
bind -T copy-mode-vi y send -X copy-pipe "reattach-to-user-namespace pbcopy"\; display-message "copied to system clipboard"
Complete config for copy and pasting with mouse and vi key binding support looks like this:
set-option -g default-command "reattach-to-user-namespace -l bash"
set -g mouse on
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send -X copy-pipe "reattach-to-user-namespace pbcopy"\; display-message "copied to system clipboard"
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
## don't jump to bottom on mouse select - when vi-mode enabled - 2.4+
#unbind -T copy-mode MouseDragEnd1Pane
## don't jump to bottom on mouse select - when vi-mode enabled - 2.2 - 2.3
#unbind -t vi-copy MouseDragEnd1Pane
## don't jump to bottom on mouse select - when vi-mode enabled
unbind -T copy-mode-vi MouseDragEnd1Pane
I am using OS X.