mirror of
https://github.com/samoshkin/tmux-config.git
synced 2026-01-04 00:38:01 +00:00
Copy on MouseDragEnd event but do not reset copy mode and selection. Add shortcut to copy whole line. Strip trailing new lines from copied text
This commit is contained in:
@@ -358,9 +358,11 @@ There is a root keybinding to enter Copy mode: `M-Up`. Once in copy mode, you ha
|
||||
|
||||
`Space` starts selection, `Enter` copies selection and exits copy mode. List all items in copy buffer using `prefix C-p`, and paste most recent item from buffer using `prexix p`.
|
||||
|
||||
You can also use `y` which is equivalent to `Enter`, and `Y` will copy text, exit copy mode and immediately paste buffer to you command line.
|
||||
`y` just copies selected text and is equivalent to `Enter`, `Y` copies whole line, and `D` copies by the end of line.
|
||||
|
||||
You can also select text using mouse. Default behavior is to copy text and immediately cancel copy mode on `MouseDragEnd` event. This is annoying, because sometimes I select text just to highlight it, but tmux drops me out of copy mode and reset scroll by the end. I've changed this behavior, so `MouseDragEnd` does not execute `copy-selection-and-cancel` action. You can then copy text just by left mouse click, and continue working in copy-mode.
|
||||
Also, note, that when text is copied any trailing new lines are stripped. So, when you paste buffer in a command prompt, it will not be immediately executed.
|
||||
|
||||
You can also select text using mouse. Default behavior is to copy text and immediately cancel copy mode on `MouseDragEnd` event. This is annoying, because sometimes I select text just to highlight it, but tmux drops me out of copy mode and reset scroll by the end. I've changed this behavior, so `MouseDragEnd` does not execute `copy-selection-and-cancel` action. Text is copied, but copy mode is not cancelled and selection is not cleared. You can then reset selection by mouse click.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -175,21 +175,22 @@ if -b "command -v reattach-to-user-namespace > /dev/null 2>&1" \
|
||||
|
||||
yank="~/.tmux/yank.sh"
|
||||
|
||||
# Remap keys which perform copy to pipe copied text to OS clipboard
|
||||
# Copy selected text
|
||||
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "$yank"
|
||||
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "$yank"
|
||||
bind -T copy-mode-vi Y send-keys -X copy-pipe-and-cancel "$yank; tmux paste-buffer"
|
||||
bind -T copy-mode-vi C-j send-keys -X copy-pipe-and-cancel "$yank"
|
||||
bind -T copy-mode-vi Y send-keys -X copy-line \;\
|
||||
run "tmux save-buffer - | $yank"
|
||||
bind-key -T copy-mode-vi D send-keys -X copy-end-of-line \;\
|
||||
run "tmux save-buffer - | $yank"
|
||||
bind -T copy-mode-vi C-j send-keys -X copy-pipe-and-cancel "$yank"
|
||||
bind-key -T copy-mode-vi A send-keys -X append-selection-and-cancel \;\
|
||||
run "tmux save-buffer - | $yank"
|
||||
|
||||
# Do not copy selection and cancel copy mode on drag end event
|
||||
# Prefer iTerm style selection: select, then mouse click to copy to buffer
|
||||
unbind -T copy-mode-vi MouseDragEnd1Pane
|
||||
# Copy selection on drag end event, but do not cancel copy mode and do not clear selection
|
||||
# clear select on subsequence mouse click
|
||||
bind -T copy-mode-vi MouseDragEnd1Pane \
|
||||
send-keys -X copy-pipe "$yank"
|
||||
bind -T copy-mode-vi MouseDown1Pane select-pane \;\
|
||||
send-keys -X copy-pipe "$yank" \;\
|
||||
send-keys -X clear-selection
|
||||
|
||||
# iTerm2 works with clipboard out of the box, set-clipboard already set to "external"
|
||||
@@ -268,6 +269,7 @@ wg_battery="#{battery_status_fg} #{battery_icon} #{battery_percentage}"
|
||||
wg_date="#[fg=$color_secondary]%h %d %H:%M#[default]"
|
||||
wg_user_host="#[fg=$color_secondary]#(echo $USER)#[default]@#H"
|
||||
wg_is_zoomed="#[fg=$color_dark,bg=$color_secondary]#{?window_zoomed_flag,[Z],}#[default]"
|
||||
# TODO: highlighted for nested local session as well
|
||||
wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]"
|
||||
|
||||
set -g status-left "$wg_session"
|
||||
|
||||
@@ -7,7 +7,9 @@ is_app_installed() {
|
||||
}
|
||||
|
||||
# get data either form stdin or from file
|
||||
buf=$(cat "$@")
|
||||
# 'echo -n' to strip any trailing new lines, so when we paste in command prompt
|
||||
# it won't be executed immediately
|
||||
buf=$(cat "$@" | xargs echo -n)
|
||||
|
||||
copy_backend_remote_tunnel_port=$(tmux show-option -gvq "@copy_backend_remote_tunnel_port")
|
||||
copy_use_osc52_fallback=$(tmux show-option -gvq "@copy_use_osc52_fallback")
|
||||
|
||||
Reference in New Issue
Block a user