diff --git a/README.md b/README.md index cfe5a79..598cbab 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 66beeec..846d7c2 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -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" @@ -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" } diff --git a/yank.tmux b/yank.tmux index 3003974..e06c8a9 100755 --- a/yank.tmux +++ b/yank.tmux @@ -48,7 +48,7 @@ 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" @@ -56,7 +56,7 @@ set_copy_mode_bindings() { 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"