diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index b42a026..cd99f61 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -69,6 +69,25 @@ bind -n TripleClick1Pane { } } +# Paste primary selection with middle mouse button +bind -n MouseDown2Pane { + select-pane -t= + if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { + send -M + } { + run 'tmux set-buffer -b XA_PRIMARY "$(xclip -selection p -o)"' + paste-buffer -p -b XA_PRIMARY + } +} +# When in copy-mode do the same but leave copy-mode first +bind -T copy-mode-vi MouseDown2Pane { + select-pane -t= + send -X cancel + # TODO: Forward click to 'root' key-table to prevent code duplication + run 'tmux set-buffer -b XA_PRIMARY "$(xclip -selection p -o)"' + paste-buffer -p -b XA_PRIMARY +} + # Scroll up 5 lines when entering copy-mode through the mouse wheel, send 5x`up` # when the current pane is in alternate mode and discard the `-e` flag passed to # copy-mode from the default binding (See below)