Copy-Paste in xfce4-terminal adds 0~ and 1~

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?

Asked By: botismarius

||

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"
Answered By: remmy

I had the same issue, it occurs after I use vi.

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

For reference, this is what t_BE does:

t_BE enable bracketed paste mode

Answered By: ivan

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.

Answered By: egmont

My issue was due to a badly-closed bash session. So running command reset in my terminal solved it immediately.

Answered By: petobens

This may not apply directly to your problem, but I found this symptom to probably, in my case, be caused by my editor-of-choice ‘mcedit’ (Midnight Commander)

To alleviate the bug problem, I added the following function to my .bashrc file:

### vvv 'function mcedit' is a fix-up for the ~0/~1 paste problem
function mcedit() { command mcedit $@ ; printf 'e[?2004l' ; }

Then ‘source .bashrc’

Now every time I execute ‘mcedit’, it automatically adds the ‘printf “e[?2004l”‘ when I close out to reset the “Bracketed Paste Mode”

Works for me, YMMV.

The same approach can be used with vi, vim, nano, or any other misbehaving program.

Answered By: user83536

There is an additional way that this problem can manifest. Readline’s .inputrc file can contain the following:

set enable-bracketed-paste On

This is not fixed by any of the above methods and has eluded me for months. Removing this line or setting

set enable-bracketed-paste Off

will fix this nicely.

Answered By: DanG
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.