Miscellaneous tips

Copy and Paste

In character mode the “standard” keyboard shortcuts for copy and paste (ctrl-C and ctrl-V) are sent to the backend program. So instead DomTerm uses ctrl-shift-C to copy the selection to the clipboard, and ctrl-shift-V to paste the contents of the clipboard.

Some front-end also have menu entries for copy and paste.

The selection is copied as both plain text (text/plain) and formatted HTML (text/html) in case the receiving application can paste the latter. The HTML is slightly cleaned up from the raw DOM (in the same way Save as HTML does). Note that only inline styling is copied; no attempt is made to merge in style rules from stylesheets.

The Copy as HTML command places the formatted HTML in the clipboard as text/plain so you can paste the HTML into a text editor.

Front-end support: Middle-button paste (i.e. clicking the middle button pastes the contents of the selection, rather than the clipboard) works on qtdomterm, and chrome-based browsers. It does not work in a Firefox browser window.

Save the console contents as HTML

Use the keyboard shortcut ctrl-shift-S to save the contents of the DomTerm console as an HTML file. Both qtdomterm and the Electron front-end also offer menu entries for this.

The saved file should be viewed with various css stylesheet files in the hlib subdirectory. You can create a symlink to the hlib subdirectory in the DomTerm distribution. The saved file also optionally makes use of some JavaScript, in the same directory. The JavaScript isn’t essential, but it enables features like hide/show buttons and dynamic line-(re-)breaking.

Images will preserve their URLs. Relative URLs may need to be fixed, but absolute ones should be fine. “Embedded” images using a data: URL (including those loaded with the image sub-command) will be saved embedded, and Just Work.

The resulting file is actually an XHTML file, so you can use XML tools to extract parts from or transform the output.

Front-end support: The qtdomterm and the Firefox/XUL applications bring up a file chooser, and let you save the file in any writable directory. Other front-end bring up a prompt pop-up and only allow saving to the Downloads area. The JavaFX front-end currently does not support saving.

Note that if DomTerm is running in a browser window, the browser’s Save page as ... command is not useful. It will save the original bare web page, before any DomTerm interactions or other JavaScript modification.

Adding domterm or qtdomterm to the desktop

On Gnome or KDE

Copy domterm/domterm.desktop or qtdomterm/qtdomterm.desktop to either /usr/share/applications (if domterm is installed in /usr/bin and you want it accessible to everyone), or in ~/.local/share/applications (if you only wish to make accessible to a single user).

Environment variables set

The DomTerm back-ends set various enviromnent variable when they start up a process.

TERM is set to "xterm-256color". COLORTERM is set to "truecolor".

The DOMTERM variable is set to a semicolon-separate list of information about DomTerm and how it was invoked. The specific list is subject to change.

An example when running on qtdomterm:

QtDomTerm;version=0.80;tty=/dev/pts/3

The Electron front-end may yield:

version=0.80;electron=1.3.13;libwebsockets=2.1.1;tty=/dev/pts/1

Checking the DOMTERM variable is a simple way to check if we’re running in a DomTerm terminal. It is not foolproof, as explained here.

WINDOWID is not set - in fact qtdomterm unsets it. There seem to be some problems setting it with Qt. This variable is not set by Wayland.

Various programs

Newer versions of the GNU ls programs support a --hyperlink option that creates a file: link for each filename. The escape sequence is also recognized by gnome-terminal, and should be harmless for other xterm-like terminals. Consider adding this to your shell init file:

case "$TERM" in
  *xterm*) alias ls='ls --hyperlink=auto';;
esac

gnuplot

The gnuplot graphing application has builtin support for “printing” graphical output to the DomTerm console

pandoc Printing markdown and other document types

The pandoc program can convert documents between multiple document formats. To view a Markdown document doc.md you can do:

pandoc -t html doc.md | domterm hcat

You might optionally use the --self-contained flag to force images to be “inlined” in the terminal output:

pandoc -t html --self-contained --metadata pagetitle=dummy doc.md | domterm hcat

(The --metadata pagetitle=dummy is to silence an annoying warning.)

Showing man pages as html

To view the bash man page inline you can do the following. This works best with Automatic Pager set.

man -Hcat bash 2>/dev/null|domterm hcat

Moving input cursor using mouse clicks

Many interactive programs support simple editing of the current input line. There are a number of libraries for this (for example as GNU readline), that support moving the cursor using arrow keys but do not handle the mouse.

In “readline mode” a mouse click is translated into arrow key presses that should move the cursor to the clicked position, assuming the interactive program understands arrow keys.

There are two ways to enable readline mode for a mouse click: