How to configure the double click behavior in an X terminal?
You do it with X resources. I have a file,
.Xresources, that contains these xterm-related resources:
XTerm*VT100.cutNewLine: false XTerm*VT100.cutToBeginningOfLine: false XTerm*VT100.charClass: 33:48,35:48,37:48,42:48,45-47:48,64:48,95:48,126:48
.xinitrc file, I have some line that merge in those resources:
if [ -f $userresources ]; then /usr/X11/bin/xrdb -merge $userresources fi
Those lines make xterm double-clicks and triple-clicks do what I like:
Double-click considers a "word" to include slash (/), dot (.), asterisk (*) and some other non-alphanumeric characters. That's the "charClass" resource. I had to do some tedious fiddling with that charClass to get it to do what I want. That mostly lets you double-click on URLs and fully- or partially-qualified paths to highlight them.
The other two lines make triple-click start from the word under the mouse, and go to the end of the line, but not include any new-line. That way, you can triple click on a command you just executed, paste it in another window, and because it has no new-line, you can edit it before running it in the other window.
The Arch Wiki has an article on X resources, including a section on xterm resources, but those xterm resources aren't complete.
xterm has several resource-settings related to double- and triple-clicking for selection (the manual page lists all of the relevant resources):
If "false", triple clicking to select a line does not include the Newline at the end of the line. If "true", the Newline is selected. The default is "true".
If "false", triple clicking to select a line selects only from the current word forward. If "true", the entire line is selected. The default is "true".
Specify selection behavior in response to multiple mouse clicks. A single mouse click is always interpreted as described in the Selection Functions section (see POINTER USAGE). Multiple mouse clicks (using the button which activates the select-start action) are interpreted according to the resource values of on2Clicks, etc. The resource value can be one of these:
Select a "word" as determined by the charClass resource. See the CHARACTER CLASSES section.
Select a line (counting wrapping).
Select a group of adjacent lines (counting wrapping). The selection stops on a blank line, and does not extend outside the current page.
Select all visible lines, i.e., the page.
Select all lines, i.e., including the saved lines.
Select a "word" as determined by the regular expression which follows in the resource value.
No selection action is associated with this resource. Xterm interprets it as the end of the list. For example, you may use it to disable triple (and higher) clicking by setting on3Clicks to "none".
The default values for
on3Clicksare "word" and "line", respectively. There is no default value for
on5Clicks, making those inactive. On startup, xterm determines the maximum number of clicks by the
onXClicksresource values which are set.