I use xubuntu 14.04, 64 bit. Every now and then, when I try to paste some text in xfce4-terminal, instead of the expected text to be pasted, it is surrounded by 0~ and 1~, such as:

0~mvn clean install1~

The text is supposed to be mvn clean install -- I verified this by pasting the content in various other applications (gnome-terminal, gedit and others). Every application pastes correctly the content, except xfce4-terminal. I couldn't find any references for this on the internet (unfortunately, it is hard to search for text with special characters on google.com...). Why does this happen?

share|improve this question
    
How are you pasting? Middle click, or something else? – Celada Apr 15 '15 at 0:02
    
I've tried every method: middle click, right click and chose option paste, ctrl+shift+v. When the 0~ and 1~ characters appear, it does not matter which pasting method I use. – botismarius Apr 15 '15 at 10:38
up vote 53 down vote accepted
+50

The issue is that your terminal is in bracketed paste mode, but doesn’t seem to support it properly. The issue was fixed in VTE, but xfce4-terminal is still using an old and unmaintained version of it.

You can try temporarily turning bracketed paste mode off by using:

printf "\e[?2004l"
share|improve this answer
1  
If you can’t always reproduce it it might be that you were running some program that enabled bracketed paste mode and then it crashed, thus wasn’t able to disable it before exiting. – kyrias Apr 16 '15 at 13:46
2  
Awesome, thanks! I've been struggling with this issue for more than a year. Is it possible to disable this "bracketed paste mode" completely? BTW, who implements such crazy things? ;) – Adam Romanek Apr 13 '16 at 13:00
2  
it depends on your terminal. And it is a really useful feature, since it lets applications know whether something was typed in or pasted. For one, weechat, an IRC program, uses it to ask if you want to send multi-line pastes, which it couldn't do without bracketed paste mode, since then there would be no way to know if the user typed the lines or not. – kyrias May 4 '16 at 10:42
1  
How can I find which program is messing with bracketed paste mode? – aviggiano Jul 12 '17 at 16:49
1  
For distributions based on Ubuntu you can try to install patched version of 'vte' package from launchpad.net/~adrozdoff/+archive/ubuntu/vte – Denis Bakharev Oct 21 '17 at 21:22

I had the same issue, it occurs after i use VI

mine was resolved by adding set t_BE= to my .vimrc file

share|improve this answer

This behavior occurs when the terminal emulator is stuck in bracketed paste mode.

This typically happens when an application exits uncleanly (crashes or is buggy).

Another reason for the phenomenon to occur frequently is a bug in older versions of VTE (VTE is the terminal emulation widget under gnome-terminal and xfce4-terminal and many more) which is triggered by certain actions in certain utilities such as toggling the panels in Midnight Commander.

To see if this bug is fixed in the VTE-based terminal emulator you're running: Execute echo -ne '\e[>c', this will insert a few characters as if you typed them. If the middle number is 3602 or bigger, the aforementioned old VTE bug is no longer present for you. If the number is smaller than that, VTE is still affected and gets stuck in bracketed paste mode more often than it should.

To see if a certain terminal emulator is fixed in a certain Ubuntu distribution, check its dependencies on packages.ubuntu.com. libvte-2.91-0 is good. libvte-2.90-9 is only good if the actual version of that package is 0.36.2 or newer, and libvte9 is bad. In particular, xfce4-terminal is buggy in Xenial, and fixed in Zesty.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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