Tips and solutions

This page covers various topics, and may evolve to a Frequently-Asked-Questions page.

Notes about “Front-end support” discuss how different front-ends may support some features differently.

Keyboard shortcuts

Control-Shift-A Control-D

 On Electron toogle Developer Window.

Control-Shift-C

Copy the selected text to the clipboard. (Control-C also works in line-editing mode.)

Control-Shift-V

Paste text from the clipboard. (Control-V also works in line-editing mode.)

Control-Shift-S

Save the display to a file.

Control-Shift-I

Cycle between the input modes: automatic, to line, to character, and back. The resulting mode is displayed temporarily.

Control-Shift-Home

Scroll to top.

Control-Shift-End

Scroll to bottom.

Control-Shift-PageUp
Control-Shift-PageDown

Scroll one “page” up or down. (Specifically, the viewport height minus a height of one line.)

Control-Shift-Up
Control-Shift-Down

Scroll one line up or down.

The following are implemented by most browsers, rather than DomTerm, so it may not work on all browsers.

Contriol-Shift-Plus

Zoom in (makes text bigger).

Control-Shift-Minus
Control-Minus

Zoom out (makes text smaller).

Control-0

“Un-zoom” to normal size.

F11

Toggle full-screen mode.

Scrolling

Control-Shift-PageUp
Control-Shift-PageDown

Scroll a page up or down, respectively.

Control-Shift-Up
Control-Shift-Down

Scroll a line up or down, respectively.

Control-Shift-Home
Control-Shift-End

Scroll to top or bottom, respectively.

See also the bindings for Paging mode.

Managing subwindows

The prefix key Control-Shift-A when followed by some other key controls sessions and windows.

Control-Shift-T

Create a new terminal in a new tab.

Control-Shift-N

Create a new terminal in a new pane (sub-window). The new pane is create to the right or below the current pane, depending on space.

Control-Shift-A Control-Left

Create a new terminal pane to the left of the current one.

Control-Shift-A Control-Right

Create a new terminal pane to the right of the current one.

Control-Shift-A Control-Up

Create a new terminal pane above the current one.

Control-Shift-A Control-Down

Create a new terminal pane below the current one.

Control-Shift-A Left

Select the previous pane or tab.

Control-Shift-A Right

Select the next pane or tab.

Control-Shift-A d

Detach from current session and close the (sub-)window.

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.

Front-end support: Middle-button paste (i.e. cliicking 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.

Changing appearance with CSS stylesheets

On qtdomterm you can use the --stylesheet option or the Edit / Preferences / Appearance menu entry.

Session names and session-specific styles

Each “session” (terminal window) has a name, which by default has the form "domterm-N" where N is an integer. The session name is usually shown in the window title bar, in the format "window-title [session-name]".

You can change the session name by “printing” a certain escape sequence. For example (using bash):

echo -en "\e]30;session-name\007"

The qtdomterm application will give each session a fresh name of the form domterm-N. The Java WebSockets server will do the same.

The session name is used to set the name attribute of the top domterm element, so you can use it to select different rules for different sessions. For example the following selects different background colors.

div.domterm { background-color: #FFE }
div.domterm[name="domterm-1"] { background-color: #FEE }
div.domterm[name="domterm-2"] { background-color: #EEF }

Browser quirks and limitions

(These can all change as browsers change or work-arounds are implemented.)

Middle-button paste: Works with Chrome and qtdomterm (on Linux); does not work on Firefox.

Exiting the inferior process can sometimes fail to automatically close the DomTerm window, due to browser security limitations. It currently works on Google Chrome, but not Firefox.

Saving the console display to a file in a browser may save to the browser’s “Downloads” area. You may be able to save the file elsewhere, depending on the browser and its settings.

Using line-editing mode with the brower’s builtin editor may exhibit various quirks.

Microsoft Edge does at time of writing not handle the tab-size CSS property, so on that browser tab characters are always converted to spaces.

Adding qtdomterm to the desktop

On Gnome or KDE

Copy qtdomterm/qtdomterm.desktop to either usr/share/applications (if qtdomterm 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 the normal way to check if we’re running in a DomTerm terminal. It is not foolproof, since you could (for example) spawn off an xterm, which would not reset the DOMTERM variable. To make it more robust, you can compare the output of the tty command or the ttyname function with the value specified after tty=. However, tty= might not be specified unless runnng under a pty.

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.

Setting the Bash shell prompt

You can place the following in your ~/.bashrc to take advantage of DomTerm features:

if [ "$PS1" != "" ]
then
  # Optionally override the system default - for all terminals
  PS1='$ ' # or whatever

  # Check if the DOMTERM variable includes the string "tty=ttyname"
  # where ttyname is the output from the tty command
  case ";$DOMTERM;" in
    *";tty=`tty`;"*) ;;
    *";tty="*) unset DOMTERM;;
  esac

  if [ -n "$DOMTERM" ]
  then
    # Add some DomTerm-specific escape sequences
    PS1='\[\e[19u\e[16u\]▼\[\e[17u\e[14u\]'$PS1'\[\e[15u\]'
    PS2='\[\e[14u\]'$PS2'\[\e[18u\]'
  fi
fi

This causes the prompt to have the prompt style (specifically to be in a <span std="prompt"> element), while the remainder of the current line gets the input style (specifically, in a <span std="input"> element). The appearance of these styles can be customized with CSS stylesheets.

Furthermore, this prompt enables text folding: a hide/show button (click on the character), which hides/shows the output from the command.

See the Wire byte protocol section for the details.

(The "\[" and "\]" are bash syntax, and are equivalent to readline’s "\001" and "\002". They are used to indicate escape sequences that don’t move the cursor, which is needed for readline to calculate the column position.)