tmux: Paste primary selection with middle mouse
Similar to everywhere else, paste the primary X selection (XA_PRIMARY) instead of the most recent tmux paste buffer. TODO: Forward event to 'root' key-table to prevent code duplication
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user