Skip to main content
Updated version 3
Source Link
Hugh
  • 11
  • 2
bind-key -T copy-mode-vi y run 'tmux send-keys -X copy-selection "wl-copy" ; \
tmux set -q @buffer_content "$(tmux show-buffer)"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>' \; \
run 'tmux set -u "@buffer_content"'
# Don't duplicate the following \\ with the version 4
bind-key -T copy-mode-vi \\ command-prompt -I '#{@buffer_content}' -p '(search up)' 'send -X search-backward "%%%"'
bind-key -T copy-mode-vi y run 'tmux send-keys -X copy-selection "wl-copy" ; tmux set -q @buffer_content "$(tmux show-buffer)"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>'
# Don't duplicate the following \\ with the version 4
bind-key -T copy-mode-vi \\ command-prompt -I '#{@buffer_content}' -p '(search up)' 'send -X search-backward "%%%"'
bind-key -T copy-mode-vi y run 'tmux send-keys -X copy-selection "wl-copy" ; \
tmux set -q @buffer_content "$(tmux show-buffer)"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>' \; \
run 'tmux set -u "@buffer_content"'
# Don't duplicate the following \\ with the version 4
bind-key -T copy-mode-vi \\ command-prompt -I '#{@buffer_content}' -p '(search up)' 'send -X search-backward "%%%"'
Avoid duplication
Source Link
Hugh
  • 11
  • 2
bind-key -T copy-mode-vi y run 'tmux send-keys -X copy-pipeselection "wl-copy" ; tmux set -q @buffer_content "$(tmux show-buffer)"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>'
# Don't duplicate the following \\ with the version 4
bind-key -T copy-mode-vi \\ command-prompt -I '#{@buffer_content}' -p '(search up)' 'send -X search-backward "%%%"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>'

Here is a related link Run arbitrary command in tmux copy mode. The method it provides is the same as the method I use. It has the advantage of automatic copying selection since it must work under the copy-mode (via send-keys), which implementation still requires caching to a custom tmux variable on my machine and should use the "-I" interface. TheMy relevant version shows below Run arbitrary command in tmux copy mode:

bind-key -T copy-mode-vi \\ send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -I '#{@buffer_command}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi !: send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -p '>' -I '#{@buffer_command}' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi y run 'tmux send-keys -X copy-pipe "wl-copy" ; tmux set -q @buffer_content "$(tmux show-buffer)"'
bind-key -T copy-mode-vi \\ command-prompt -I '#{@buffer_content}' -p '(search up)' 'send -X search-backward "%%%"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>'

Here is a related link. The method it provides is the same as the method I use. It has the advantage of automatic copying selection since it must work under the copy-mode (via send-keys), which implementation still requires caching to a custom tmux variable on my machine and should use the "-I" interface. The relevant version shows below Run arbitrary command in tmux copy mode

bind-key -T copy-mode-vi \\ send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -I '#{@buffer_command}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi ! send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -p '>' -I '#{@buffer_command}' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi y run 'tmux send-keys -X copy-selection "wl-copy" ; tmux set -q @buffer_content "$(tmux show-buffer)"'
bind-key : command-prompt -I '#{@buffer_content}' -p '>'
# Don't duplicate the following \\ with the version 4
bind-key -T copy-mode-vi \\ command-prompt -I '#{@buffer_content}' -p '(search up)' 'send -X search-backward "%%%"'

Here is a related link Run arbitrary command in tmux copy mode. The method it provides is the same as the method I use. It has the advantage of automatic copying selection since it must work under the copy-mode (via send-keys), which implementation still requires caching to a custom tmux variable on my machine and should use the "-I" interface. My relevant version shows below:

bind-key -T copy-mode-vi \\ send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -I '#{@buffer_command}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi : send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -p '>' -I '#{@buffer_command}' \; \
run 'tmux set -u "@buffer_command"'

Added update version
Source Link
Hugh
  • 11
  • 2

This version avoids the problems of the first two versions (but still does not implement the paste action itself). I apply it to two situations: whether copying screen content into the "copy-mode-vi" mode search box or the line editor of the "command-prompt" mode interactive window, it is based on the same logic: define an additional @buffer_content to store the latest buffer variable, it will be automatically pasted into the currently executing line editor in its original form. You can edit and submit the content normally for further processing. Version

Here is a related link. The method it provides is the same as the method I use. It has the advantage of automatic copying selection since it must work under the copy-mode (via send-keys), which implementation still requires caching to a custom tmux variable on my machine and should use the "-I" interface. The relevant version shows below Run arbitrary command in tmux copy mode

Version 4 A

bind-key -T copy-mode-vi \\ send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -I '#{@buffer_command}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi ! send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -p '>' -I '#{@buffer_command}' \; \
run 'tmux set -u "@buffer_command"'

A related discussion How can I search within the output buffer of a tmux shell?

This version avoids the problems of the first two versions (but still does not implement the paste action itself). I apply it to two situations: whether copying screen content into the "copy-mode-vi" mode search box or the line editor of the "command-prompt" mode interactive window, it is based on the same logic: define an additional @buffer_content to store the latest buffer variable, it will be automatically pasted into the currently executing line editor in its original form. You can edit and submit the content normally for further processing. Version 4 A related discussion How can I search within the output buffer of a tmux shell?

This version avoids the problems of the first two versions (but still does not implement the paste action itself). I apply it to two situations: whether copying screen content into the "copy-mode-vi" mode search box or the line editor of the "command-prompt" mode interactive window, it is based on the same logic: define an additional @buffer_content to store the latest buffer variable, it will be automatically pasted into the currently executing line editor in its original form. You can edit and submit the content normally for further processing.

Here is a related link. The method it provides is the same as the method I use. It has the advantage of automatic copying selection since it must work under the copy-mode (via send-keys), which implementation still requires caching to a custom tmux variable on my machine and should use the "-I" interface. The relevant version shows below Run arbitrary command in tmux copy mode

Version 4

bind-key -T copy-mode-vi \\ send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -I '#{@buffer_command}' -p 'search up>' 'send -X search-backward "%%%"' \; \
run 'tmux set -u "@buffer_command"'

bind-key -T copy-mode-vi ! send-keys -X copy-selection \; \
run 'tmux set -q @buffer_command "$(tmux show-buffer)"' \; \
command-prompt -p '>' -I '#{@buffer_command}' \; \
run 'tmux set -u "@buffer_command"'

A related discussion How can I search within the output buffer of a tmux shell?

added 9 characters in body
Source Link
Hugh
  • 11
  • 2
Loading
deleted 262 characters in body
Source Link
End Antisemitic Hate
  • 8.5k
  • 34
  • 85
  • 138
Loading
precise wording
Source Link
Hugh
  • 11
  • 2
Loading
Exclude irrelevant scenarios
Source Link
Hugh
  • 11
  • 2
Loading
More details added
Source Link
Hugh
  • 11
  • 2
Loading
Add a complete statement
Source Link
Hugh
  • 11
  • 2
Loading
Add original post title
Source Link
Hugh
  • 11
  • 2
Loading
Source Link
Hugh
  • 11
  • 2
Loading