firefox

Firefox and many other X applications that support clipboard operations (^X/^C/^V) do not always play well with some other X applications (most notably, xterm). This is because there are several selection types in X. The "select with the mouse and it is there for you" is called PRIMARY selection. The "^C to copy, ^V to paste" one is called, not surprizingly, CLIPBOARD. There can be more, but those two are the ones used the most. The problem is that sometimes when you create a selection in an xterm, you really mean to paste it in an application that pastes from another selection type, and the other way around. Some would argue that having multiple selection types (just names, really) is a fact of life. Some would probably try to persuade you that this distinction is somehow useful. Me, I would just say that it is annoying. So, before trying to hack something up, I googled a bit, and found this page. David Simmons presents a couple of xterm patches, one of which does exactly what I want, making any xterm selection to use both PRIMARY and CLIPBOARD buffers. His patch requires recompiling xterm, although he mentions that the same effect can be achieved with X resources manipulation. David left that part as an exercise to the reader. For the reference, here is the solution. Put the following into your ~/.Xdefaults file: XTerm.vt100.translations: #override\n\   Shift <KeyPress> Select:select-cursor-start() select-cursor-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\   Shift <KeyPress> Insert:insert-selection(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\   ~Ctrl ~Meta <Btn2Up>:insert-selection(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\   <BtnUp>:select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\ Reload your resources with xrdb, or restart your X session. Enjoy.

comment 1
That's been driving me mad for a while; thanks!
Comment by Ceri Davies Fri Sep 30 16:23:38 2005
comment 2
Your xterm hints have pulled me back from the brink of insanity. Many thanks.
Comment by Philip Yarra Mon Feb 13 01:56:01 2006
comment 3
Thanks a lot for this one.
Comment by Ranjit Fri Jun 1 15:31:04 2007
comment 4
thanks for the xterm paste fix!
Comment by t3soro Wed Oct 22 08:44:55 2008
comment 5

Nice fix.

Though it seems as your blog-tool stripped the underscores in CUT_BUFFER0.

Using the fix with CUTBUFFER0 instead (as observed in the post), somehow breaks double-click selections and multiple pastes in xterm. Re-entering the underscores makes the fix work as expected.

Also, i needed to set eightBitInput: false - otherwise my metaSendsEscape didn't work (even when xev and xmodmap showed it did). Eg. alt+backspace returned ΓΏ instead of ESC+backspace.

So: CLIPBOARD/PRIMARY-fix + metaSendsEscape + eightBitInput makes my life a whole lot easier - thanks :)

Comment by Michal Mon Nov 3 14:59:47 2008