7

Question: How do I increase the copy-buffer size in tmux?

Data: When I run the following command...

$ for i in {1..1000}; do echo "$i"; done  

... and highlight the entire output in tmux (using either the mouse or keyboard commands), here is what gets sent to the system pasteboard:

1  
2  
3  
4  
--snip--
205  
206  
207  
208  
20   (<--- Notice where it cuts off)

Triage:
- This persists when I quit tmux and kill the server, move tmux.conf and launch a fresh tmux instance with the default conf file. (Having to re-learn the default keys was difficult X_X).
- Also persists on a different machine (again, with default tmux settings) with the exact software (listed below).
- Also persists in default Terminal.app (again, with default tmux settings)

System:
OS X 10.9.2
tmux 1.9a (homebrew) + reattach-to-user-namespace (homebrew)
iTerm Build 1.0.0.20140421

  • Did you ever figure this out? I can't believe it's been over a year and no one else as responded. – Dave Albert Jul 1 '15 at 8:31
1

After reading this article I learned about the new copy-pipe command that was added to tmux 1.8:

copy-pipe mode command to copy selection and pipe the selection to a command.

Changing your copy-mode bindings to use the new copy-pipe command fixed the problem for me:

# (from my tmux.conf)...
# Change copy / paste bindings to work like Vim
# Note this used to use `copy-selection` but that has been replaced
# with `copy-pipe` as of Tmux 1.8. See: https://goo.gl/ea3CRO
bind Escape copy-mode
bind p paste-buffer
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
| improve this answer | |
0

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 ]
| improve this answer | |
-1

This seems to have worked for me:

https://stackoverflow.com/a/24973743/35003

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.