Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux mouse copy-mode jumps to bottom

I am using tmux in a ssh session. I am using multiple panes and windows.

I have mouse-mode enabled which works great so far.

When I select text it gets automatically copied to the tmux-buffer and the window jumps to the end. So if i scroll up and click on something it jumps to the end... When I switch between panes a copy command is triggered and the output goes to the end. I really dislike this behaviour and I'd rather have to press a button to copy or click q to finish copy mode or something.

Is it possible to disable auto-copy // auto jump to the end on mouse button release?

I am running tmux 2.0 on the server through ssh. In Terminator on the client.

# config                                                                        
#{{{                                                                            
                                                                                
# 0 is too far from ` ;)                                                        
set -g base-index 1                                                             
                                                                                
# Automatically set window title                                                
# set-window-option -g automatic-rename on                                      
# set-option -g set-titles on                                                   
                                                                                
set -g default-terminal screen-256color                                         
set -g history-limit 10000                                                      
                                                                                
set -g status-keys vi                                                           
setw -g mode-keys vi                                                            
setw -g mode-mouse on                                                           
set -g mouse-select-window on                                                   
set -g mouse-select-pane on                                                     
set -g mouse-resize-pane on                                                     
                                                                                
# No delay for escape key press                                                 
set -sg escape-time 0                                                           
                                                                                
#}}}                                                                            
                                                                                
# bind keys                                                                     
#{{{                                                                            
# Reload tmux config                                                            
bind r source-file ~/.tmux.conf                                                 
                                                                                
# remap prefix to Control + a                                                      
set -g prefix C-a                                                                  
# bind 'C-a C-a' to type 'C-a'                                                     
bind C-a send-prefix                                                               
unbind C-b                                                                         
                                                                                   
# switch tabs with <b n>                                                           
bind b previous-window                                                             
                                                                                   
# vi like paste                                                                    
bind-key p paste-buffer                                                            
                                                                                   
# quick pane cycling                                                               
unbind a                                                                           
bind a select-pane -t :.+                                                          
                                                                                   
bind-key v split-window -h                                                         
bind-key s split-window -v                                                         
                                                                                   
bind-key J resize-pane -D 10                                                       
bind-key K resize-pane -U 10                                                       
bind-key H resize-pane -L 10                                                       
bind-key L resize-pane -R 10                                                       
                                                                                   
bind-key M-j resize-pane -D 2                                                      
bind-key M-k resize-pane -U 2                                                      
bind-key M-h resize-pane -L 2                                                      
bind-key M-l resize-pane -R 2                                                      
                                                                                   
# Vim style pane selection                                                         
bind h select-pane -L                                                              
bind j select-pane -D                                                              
bind k select-pane -U        
bind -n M-Down select-pane -D                                                   
                                                                                
# find asci keycodes with "sudo showkey -a" - works only tmux >1.7              
# us-keyboard like [ ]                                                          
bind-key -r 0xc3 display 'c3 prefix binding hack'                               
bind-key -r 0xb6 copy-mode # ö                                                  
bind-key -r 0xa3 paste-buffer # ä                                               
# us { }                                                                        
bind-key -r 0x96 swap-pane -U # Ö - swap pane to prev position                  
bind-key -r 0x84 swap-pane -D # Ä - to next pos  
                               
#}}}                         



       
like image 621
stfl Avatar asked Sep 03 '15 11:09

stfl


People also ask

How do I copy mouse mode in Tmux?

tmux's copy mode In tmux Ctrl + b [ enters copy mode, where you can move the cursor around and select text. If you have tmux's mouse mode enabled ( set -g mouse on ) then scrolling with the scrollwheel also enters copy mode. Ctrl + b Page Up enters copy mode and scrolls up by one page.

How do I copy from clipboard to Tmux?

1. Copying to another Tmux pane/window: Here, we are using two panes for our session sess_1. a) We first enter the copy mode: b) Select the text to copy with the arrow keys and press 'Alt+w' or 'Ctrl+w'.

How do I enable mouse on Tmux?

Configure Tmux for Mouse SupportRestart Tmux or run the Tmux command source ~/. tmux. conf , and you should be able to scroll up or down the scrollback with your mouse. You'll also be able to select a pane with the mouse and resize them.


3 Answers

As of tmux 2.5 you should use

unbind -T copy-mode-vi MouseDragEnd1Pane
like image 89
Evmorov Avatar answered Sep 30 '22 12:09

Evmorov


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.

like image 41
dlouzan Avatar answered Sep 30 '22 13:09

dlouzan


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.

like image 6
schpet Avatar answered Sep 30 '22 14:09

schpet