Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tmux copy buffer limit

Whenever I copy something (usually with a mouse) from a tmux buffer, and paste it later in ViM, the contents are truncated. Last attempt gave me only about 750bytes of the full block I copied.

This is in iTerm on a Mac.

like image 823
Evert Avatar asked Mar 27 '14 20:03

Evert


3 Answers

Problem Solved. A few pointers.

  1. reattach-to-user-namespace is not required. Just pbcopy.
  2. Tested with tmux 2.3
  3. The trick is to get the MouseDragEnd1Pane event to fire off pbcopy.
  4. Use iTerm2 which means that Mouse Support just works. From tmux v2.1 only set-option -g mouse on is required.
  5. You don't need vi-copy mode. Just make sure that the MouseDragEnd1Pane is bound as below

Here is my stripped down ~/.tmux.conf

# --------------------------------
# Turn on the Mouse Support - defaults seem good
# --------------------------------
set-option -g mouse on
# when we finish "selecting" send it to pbcopy (and into the OS X buffer)
bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "pbcopy"

# --------------------------------
# Use vim keybindings in copy mode
# --------------------------------
setw -g mode-keys vi

# Setup 'v' to begin selection as in Vim
# You enter with C-b [ and then "v" - then normal keypresses to "highlight"
# .. [Enter] or "y" will select (because of below bindings)
bind-key -t vi-copy v begin-selection
#
# 'y'ank will send the selection to the OS X buffer
bind-key -t vi-copy y            copy-pipe "pbcopy"

# --------------------------------
# Update default binding of `Enter` to also use Send the selection to OS X buffer
# --------------------------------
unbind   -t vi-copy Enter
bind-key -t vi-copy Enter        copy-pipe "pbcopy"

# selecting can now be done with
#  hilighting with a mouse
#  selecting with C-b [ v .. now vi mode for selecting text
#
# pasting  can now be done with
# ⌘ - V
# C-b ]
like image 103
Ramon Avatar answered Oct 04 '22 21:10

Ramon


be sure to paste from tmux buffer

I had the same problem, and was getting the paste step wrong. I came across this post.

What I was trying to do was paste from the system clipboard simply using ctrl-v (which worked, but only partially, as you explained in your question).

Instead, pasting from the tmux buffer using ctrl-b ] does the job correctly.

like image 32
samstav Avatar answered Oct 04 '22 21:10

samstav


I had the same problem using tmux 1.8, iTerm2, and reattach-to-user-namespace. I ran across a tmux config binding that fixes the problem: it explicitly copies the last buffer selection to the clipboard:

bind-key q run "tmux save-buffer - | reattach-to-user-namespace pbcopy"

Put it in your ~/.tmux.conf, and then C-b q will pull everything into your clipboard after a selection.

like image 21
lothario Avatar answered Oct 04 '22 20:10

lothario