Skip to main content
1 of 2
pdoherty926
  • 269
  • 1
  • 3
  • 13

I believe you can achieve what you're after by:

  1. entering copy mode (prefix [)

  2. selecting some text (most likely v(isual select)/y(ank))

  3. sending it to another pane via tmux paste-buffer -t [left/right]

Here's a proof of concept I just sketched out:

Given a Ruby script called foo.rb in your current directory:

# foo.rb x = "hello there" puts x 

... and two panes, vertically split (bash in left/irb session in right), if you run cat foo.rb, enter copy-mode, yank the file's contents and then run tmux paste-buffer -t right from the left pane, you should see the following output in the right pane:

λ irb 2.5.1 :001 > x = "hello there" => "hello there" 2.5.1 :002 > puts x hello there => nil 

From there, you could write a shell script and/or wire up a key binding to prevent you from having to type out/recall tmux paste-buffer -t [left/right].

paste-buffer should also handle "ending with enter" for you. From the tmux man page's paste-buffer entry:

When output, any linefeed (LF) characters in the paste buffer are replaced with a separator, by default carriage return (CR).

You can also specify which separator paste-buffer should use via the -s flag.

pdoherty926
  • 269
  • 1
  • 3
  • 13