How to prevent iTerm2 from creating overlaps and broken lines after pasting multiline chunks of text

copy/pasteiterm

If I paste multiline chunks of text into iTerm2, I always a get mess of output. It seems limited to only some programs running interactively (such as Bash, IRB – Python / VIM work flawlessly). Using Apple's native Terminal, I can paste whatever I want wherever I want – it works. For example, this sample text (full text on pastie.org):

echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.
echo Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit.
echo Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.
echo Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor.
echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor.
echo Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet.
echo Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus.
[snip]

pasted into IRB produces this in iTerm2:

Screenshot iTerm 2

while it produces this in native Terminal:

Screenshot Terminal.app

I am running the latest versions of OSX and iTerm2. What's going wrong here?

Best Answer

From docs:

Pastes (both regular and slow) are done by splitting the text to paste into chunks. There is a delay between the transmission of each chunk. To change the speed that "paste" pastes at:

defaults write com.googlecode.iterm2 QuickPasteBytesPerCall -int 1024
defaults write com.googlecode.iterm2 QuickPasteDelayBetweenCalls -float 0.01

To change the speed that "paste slowly" pastes at:

defaults write com.googlecode.iterm2 SlowPasteBytesPerCall -int 16
defaults write com.googlecode.iterm2 SlowPasteDelayBetweenCalls -float 0.125