Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ remain in copy mode, you can set `@yank_action`:
set -g @yank_action 'copy-pipe' # or 'copy-pipe-and-cancel' for the default
```

See the section *WINDOWS AND PANES* section in the tmux man page for other
commands.

### Mouse Support

`tmux-yank` has mouse support enabled by default. It will only work if `tmux`'s
Expand All @@ -252,6 +255,15 @@ the `MouseDragEnd1Pane` event, you can do so with:
set -g @yank_with_mouse off # or 'on'
```

You can change the yank behavior for mouse selection with
`@yank_action_mouse`. By default, it uses the same value as `@yank_action`:

```tmux
# ~/.tmux.conf

set -g @yank_action_mouse 'pipe-no-clear'
```

If you want to remain in copy mode after making a mouse selection, set
`@yank_action` as described above.

Expand Down
7 changes: 7 additions & 0 deletions scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ yank_with_mouse_option="@yank_with_mouse"
yank_action_default="copy-pipe-and-cancel"
yank_action_option="@yank_action"

# NOTE: `yank_action_mouse` falls back to `yank_action` if the option is not set
yank_action_mouse_option="@yank_action_mouse"

shell_mode_default="emacs"
shell_mode_option="@shell_mode"

Expand Down Expand Up @@ -93,6 +96,10 @@ yank_action() {
get_tmux_option "$yank_action_option" "$yank_action_default"
}

yank_action_mouse() {
get_tmux_option "$yank_action_mouse_option" "$(yank_action)"
}

shell_mode() {
get_tmux_option "$shell_mode_option" "$shell_mode_default"
}
Expand Down
4 changes: 2 additions & 2 deletions yank.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ set_copy_mode_bindings() {
tmux bind-key -T copy-mode-vi "$(yank_put_key)" send-keys -X copy-pipe-and-cancel "$copy_command; tmux paste-buffer -p"
tmux bind-key -T copy-mode-vi "$(yank_wo_newline_key)" send-keys -X "$(yank_action)" "$copy_wo_newline_command"
if [[ "$(yank_with_mouse)" == "on" ]]; then
tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
tmux bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X "$(yank_action_mouse)" "$copy_command_mouse"
fi

tmux bind-key -T copy-mode "$(yank_key)" send-keys -X "$(yank_action)" "$copy_command"
tmux bind-key -T copy-mode "$(put_key)" send-keys -X copy-pipe-and-cancel "tmux paste-buffer -p"
tmux bind-key -T copy-mode "$(yank_put_key)" send-keys -X copy-pipe-and-cancel "$copy_command; tmux paste-buffer -p"
tmux bind-key -T copy-mode "$(yank_wo_newline_key)" send-keys -X "$(yank_action)" "$copy_wo_newline_command"
if [[ "$(yank_with_mouse)" == "on" ]]; then
tmux bind-key -T copy-mode MouseDragEnd1Pane send-keys -X "$(yank_action)" "$copy_command_mouse"
tmux bind-key -T copy-mode MouseDragEnd1Pane send-keys -X "$(yank_action_mouse)" "$copy_command_mouse"
fi
else
tmux bind-key -t vi-copy "$(yank_key)" copy-pipe "$copy_command"
Expand Down