This page describes two hacks for the xterm program:
The xterm program is the traditional terminal emulator for the X Window System. In layman's terms, xterm is the text window used to interact with command-line and non-graphical UNIX applications, such as the UNIX shell, vi, pine, and such. An xterm window usually looks something like this:
The xterm program is somewhat antiquated, because modern desktop environments usually provide their own terminal emulator program that integrates seamlessly into the environment. For example, GNOME provides the "GNOME Terminal" and KDE provides "Konsole". However, many people -- especially old timers like myself -- prefer the simplicity of xterm.
On this page, I describe a couple of hacks which I find to be valuable additions to the xterm experience. The first hack adds a "full screen" feature to xterm, and the second fixes the annoying "copy and paste" incompatibilities between xterm and modern applications such as Firefox.
While using the excellent, free PuTTY ssh client in Windows, I became hooked on its "full screen" mode which can be invoked with the Alt-Enter keystroke (if support for this is enabled in the preferences.) When using the program in full-screen mode, the contents of the window occupy the full screen and there are no decorations such as menus, toolbars, the desktop environment's "Start" menu, etc. I find this mode useful when I'm viewing a large amount of information, or when I don't want to be distracted by the desktop environment.
Implementing a full-screen mode would have been more difficult back in the early days of X11 and xterm. However, modern desktop environments make it easy by allowing applications to simply set the "_NET_WM_STATE_FULLSCREEN" property on their windows. I've produced a patch to xterm for toggling full-screen mode when either the Alt-Enter keystroke is received, or the "fullscreen" option is selected from xterm's "Main Options" menu.
This feature works well in GNOME, and I would guess it also works in KDE. The last time I checked, the Window Maker window manager still did not have support for the _NET_WM_STATE_FULLSCREEN property.
To install the fullscreen patch, you must download the xterm source code and the fullscreen patch, then compile the source according to the instructions in the "compiling xterm" section below.
Many xterm users are frustrated because it is difficult to copy text from an xterm and paste it into modern applications such as Firefox. The root of the problem is that there are two different "selection buffers" that are commonly used in the X Window System:
The annoyance is that text highlighted in xterm cannot be pasted into a modern application with CTRL-V (or Edit->Paste). The middle mouse button usually works for pasting, but the PRIMARY buffer is often overwritten by inadvertent highlighting before the user is ready to paste. For example, if a user highlights a URL in an xterm, switches to Firefox, and presses ALT-D to navigate to the URL bar, then Firefox will automatically highlight the old contents of the URL bar, thus overwriting the highly volatile PRIMARY buffer before the user can paste the new URL!
Further details about the proper use of X selection buffers are available on this excellent page at freedesktop.org.
To solve the problem, I've created a "copynpaste" patch which causes xterm to copy text into both the PRIMARY and CLIPBOARD when a selection is highlighted, and text is pasted from CLIPBOARD if there is no data available in PRIMARY. I believe this results in the most sane behavior. With this patch, you can highlight a URL in xterm and paste it into the Firefox URL bar with CTRL-V!
To install the copynpaste patch, you must download the xterm source code and the copynpaste patch, then compile the source according to the instructions in the "compiling xterm" section below.
Alpha X11 propeller heads may notice that the patch actually just modifies the built-in default "translations" resource to add CLIPBOARD to the list of selection buffers it uses. This means that it is theoretically possible to add support for CLIPBOARD without recompiling, by adding an appropriate entry to your .Xdefaults or XTerm app-defaults file! This is left as an exercise for the reader.
Added July 3, 2007.
cweich has provided the solution (hinted at in the previous paragraph) to using friendly copy-and-paste without patching and recompiling:
Hi David, It has taken me a while but your source helped me to find a softer version for the Xterm Copy and Paste trick. (I used to compile your program, but our sysadmin was not very happy about this due to obvious updating issues.) So the patch lines helped me to find out that for the Copy & Paste functionality one simply needs to add the following line to the ~/.Xresources file: XTerm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) You can test it with an xterm: xterm -xrm 'XTerm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)' Maybe you want to add this hint to your page. I suppose there is a certain number of people who use the hacked xterm source.
Installing patches to xterm (such as the fullscreen and copynpaste patches) involves downloading the xterm source code, patching the source code, compiling the source, and installing the resulting binary.
tar xvfpj xterm-XF86-4.3.0.tar.bz2
patch -p1 < ../xterm-fullscreen.patch
patch -p1 < ../xterm-copynpaste.patch
cp -p xterm /usr/local/bin/Make sure that /usr/local/bin is in your default PATH environment variable. If you are brave, you could also install xterm with "make install", although I believe this will permanently overwrite your existing vendor-supplied xterm binary (which happens to be in /usr/X11R6/bin on my Fedora Core 3 system).
Further information about these concepts can be found on the following pages: