{"id":346,"date":"2014-05-16T13:55:37","date_gmt":"2014-05-16T11:55:37","guid":{"rendered":"http:\/\/log.or.cz\/?p=346"},"modified":"2014-05-16T13:55:37","modified_gmt":"2014-05-16T11:55:37","slug":"clipboard-cutnpaste-in-xterm","status":"publish","type":"post","link":"https:\/\/log.or.cz\/?p=346","title":{"rendered":"CLIPBOARD cut&#8217;n&#8217;paste in xterm"},"content":{"rendered":"<p>Call me old-fashioned but I&#8217;m still using xterm on my desktop computer (where I use just fluxbox as my window manager) &#8211; it suits me just fine, but for one thing that I finally managed to solve. xterm by default ignores the clipboard, and none of the previously published solutions cut it for me, until now.<\/p>\n<p>In X11, we have two commonly used selection buffers &#8211; PRIMARY and CLIPBOARD:<\/p>\n<ul>\n<li> PRIMARY is used when you simply highlight text in most applications, without pressing anything, and you can paste from it using the middle mouse button; it is of fleeting nature and used for quick cut&#8217;n&#8217;paste; and it doesn&#8217;t work well with all applications, e.g. libreoffice doesn&#8217;t put highlighted stuff there at least in some contexts and non-textarea HTML5 text edit widgets usually can&#8217;t handle the middle button for pasting.\n<li> CLIPBOARD is used when you use ctrl-c or ctrl-v and can be used even with the evil applications above, but the problem is it&#8217;s not supported by xterm well!\n<\/ul>\n<p>In most terminal emulators, you can use the clipboard either using menus or shift-ctrl-c \/ shift-ctrl-v. However, in xterm, the best you can do is either&#8230;<\/p>\n<ul>\n<li> <a href=\"http:\/\/www.starnet.com\/xwin32kb\/copy_and_paste_in_xterm\">Make it use CLIPBOARD just instead of PRIMARY<\/a> and in the same manner &#8211; the moment you select any text in xterm, it will plaster it over whatever else was in the CLIPBOARD before, without any explicit action. This sucks.\n<li> Have a <a href=\"http:\/\/linux.seindal.dk\/2005\/06\/16\/xterm-and-the-clipboard\/\">different set of bindings<\/a> for selection to PRIMARY and CLIPBOARD. This is a lot better, but I&#8217;m out of modifiers since I use shift to cut&#8217;n&#8217;paste in terminal applications that use mouse themselves (e.g. elinks).\n<\/ul>\n<p>So, my solution is to bring in the shift-ctrl-c \/ shift-ctrl-v bindings! In your ~\/.Xresources or ~\/.Xdefaults, add<\/p>\n<pre>\r\nXTerm*VT100.*translations:      #override \\\r\n        Shift Ctrl <KeyPress>C: select-end(CLIPBOARD, CUT_BUFFER0) \\n\\\r\n        Shift Ctrl <KeyPress>V: insert-selection(CLIPBOARD, CUT_BUFFER0)\r\n<\/pre>\n<p>(and don&#8217;t forget to <code>xrdb ~\/.Xresources<\/code> afterwards).<\/p>\n<p>Now, you can use shift-ctrl-v for pasting from CLIPBOARD, and <em>almost<\/em> use shift-ctrl-c for copying to clipboard. There is a catch &#8211; you must press shift-ctrl-c while you are still holding the mouse button, i.e you press left mouse button, drag your selection, then before releasing it, press shift-ctrl-c; thankfully, that can be done by one hand without too much cramping.<\/p>\n<p>It&#8217;s a bit inconvenient because of this bug, and doesn&#8217;t quite work with <a href=\"http:\/\/lukas.zapletalovi.com\/2013\/07\/hidden-gems-of-xterm.html#left-and-right-selection\">left and right selection<\/a>; maybe I will sometime get around to adding true clipboard support to xterm code, but I think this is good enough for me at this point. :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Call me old-fashioned but I&#8217;m still using xterm on my desktop computer (where I use just fluxbox as my window manager) &#8211; it suits me just fine, but for one thing that I finally managed to solve. xterm by default ignores the clipboard, and none of the previously published solutions cut it for me, until [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[137,136,22],"class_list":["post-346","post","type-post","status-publish","format-standard","hentry","category-linux","tag-clipboard","tag-x11","tag-xterm"],"_links":{"self":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346"}],"version-history":[{"count":1,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":347,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/346\/revisions\/347"}],"wp:attachment":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}