The domterm command ¶
The domterm command is the preferred away of using DomTerm.
The command has various sub-commands and options.
Most sub-commands will start a server in the background
if one isn’t already running.
If you run domterm with no arguments, it creates a new terminal
emulator window, just as if you’d start xterm, say.
You can specify options to specify what kind of window is
created (for example a new tab or a web browser window).
You can also specify a command to perform other actions
besides creating a new terminal emulator.
domterm [options] [command arg...]
The command specifies one of a set of commands used to control
domterm, as described in the following sections.
If command is not specified, the default command is new,
which creates a new session using a default shell such as /bin/bash.
Communicating with a remote computer ¶
You can run a command on a different (remote) computer named host, using the following syntax:
domterm[options] user@host [command arg...]
This uses ssh.
For details see here:
- Creating a new session
- Browser specifier option
- Window specifier option
- Miscellaneous commands
- “Printing” images or html
- Sessions
- Windows operations
- Automation
- Miscellaneous options
- Starting a web server
Creating a new session ¶
Creating a new session is done with the new commands,
possibly abbreviated:
[new] [executable arg...]
This creates a new process running the executable with the specified command-line arguments.
You can leave out the new if the executable
contains a “/” (slash). For example:
$ domterm /bin/csh -v
If executable is not specified, the default shell
(for example bin/bash) is used.
(See shell.default in Settings.)
The executable runs a new terminal window, as specified a window specifier.
The following options control which front-end (usually a browser), if any, is started.
Browser specifier option ¶
A browser-specifier option specifies how to display a new domterm window. This can be a window or tab in general-purpose web-browser, a specialized browser without locationbar or similar distracting “chrome”, or a sub-window.
It is used for certain commands like new and attach.
For example:
domterm --Belectron new domterm --below attach 4 domterm --browser /bin/sh
If there is no browser-specifier option,
the value of the browser.default setting is used.
Browser specifiers ¶
--browser-BCreates a new window or tab in your preferred desktop browser. Same as
-Bbrowser.
-Bcommand--browser=commandFor example either
-Bfirefoxor--browser=firefox(which are equivalent).The command is most commonly one of the browser aliases below. Can also be a command with an optional
%U, which is replaced by a URL generated bydomterm. (If there is no%Uin the command, then ‘ '%U'’. is added.) You can also specify a list of commands or aliases, separated by semi-colons, which are tried in order.If program is specified, instead creates a window in the specified browser, where program is the name of a browser program that takes a single URL argument. The program can be a multi-word template, where
%Uis replaced by a URL generated bydomterm. If program contains a ‘$’ it is processed by the shell; the program should either deamonize itself or otherwise run in the background (perhaps by using ‘&’). If program does not contain a ‘$’,domtermsplits it into words and runs it directly (daemonized).
The following aliases are available.
firefoxchromegoogle-chromesafari(macOS only)edge(Windows only)-
Open a new tab or window in the specified desktop browser, either Firefox, Google Chrome (
chromeandgoogle-chromeare synonymous), Safari (on macOS only), or Microsoft Edge (on Windows only). DomTerm looks in common platform-specific locations for these browers, and knows which options to pass. chrome-appedge-app(Windows only)The aliases
chrome-appandedge-appopenchromeoredgein “application mode” (with the--app=option). This is recommended: you don’t get the clutter of the browser location bar, menubar, or toolbar, or the browser taking over certain keybindings (like ctrl+N).electronelectron-frameselectron-widgets(Experimental)Use a front-end based on Electron. This is currently the nicest (and default) front-end.
The default (
electron-framesorelectron) uses a shared browser instance for all sub-windows in the same top-level window. The experimentalelectron-widgetsruns each sub-window is a separate browser instance, which allows a sub-window to be moved from one top-level window to another without reloading.qtqt-widgetsqt-framesqtdomtermqtwebengineThese all run the
qtdomtermfront-end, a stripped-down browser based on the Qt toolkit (specifically QtWebEngine, which is based on the Chrome browser).Except for
-Bqt-frames, these are all equivalent, and each sub-window has a separate browser instance. This has the benefit that a sub-window can be moved from one top-level window to another without reloading. In contrast,-Bqt-framesuses a shared browser instance for each top-level window and uses interior frames for sub-windows (like other front-ends).webviewwryRun the stripped-down
dt-webviewordt-wrybrowser, respectively. (Available if configured--with-webvieworwith-wry, respectively.)browserRun the default desktop browser. The option
--browser=browser(or-Bbrowser) is the same as plain--browser(or-B).
Special window specifiers ¶
The following create sub-window in existing browser windows, or have other special uses.
--left[=window]--right[=window]--above[=window]--below[=window]Split window (a window specifier) in two, and create a new pane (sub-window) to the left/right/above/below the old one. If window is not specified, use the current window.
If window starts with
^, split the specified top-level window. For example, if window 1 is above window 2, then--left=2will will put the new window side-by-side with 2, and both below window 1 (which is full-width). In contrast,--left=^2will create a new full-height window on the left, while on the right window 1 will be above window 2.--pane[=window]Equivalent to either
--rightor--belowdepending on the current window’s width/height ratio.--tab[=window]Create new tab.
--headlessCreate an “invisible” (hidden) browser window. This runs all the regular display logic except actually displaying on a screen. This (experimental) feature is useful for testing (of DomTerm or of other applications). It is also useful as a backup of the display in case of network disconnect. (The headless server runs on the same remote computer as the session.)
You should use the
command.headlesssetting to specify the command for running the headless browser. This can be any command that can take a URL argument (using with a%Upattern that is filled in bydomterm). Ifcommand.headlessis not set, but one of--chrome,--qt, or--electronis specified the corresponding frontend in used headless mode. (Using--chromeseems to work best.) If none of these are set, the default is as if--chromewas specified, assuming the Chrome browser is available.--detachedWhen creating a new session, it is detached, without a window.
--print-browser-command(Debugging use.) This option can be used with another window specifier. Print out the command that would start a new top-level browser window, but don’t actually execute that command. You can use that command to start the browser from a debugger or change the command line. The browser will first open a local file (with a
file:URL) and a filename ending withstart-windownumber.html. This file will redirect to anhttp:URL (served by thedomtermbackend) with various parameters that are interpreted by JavaScript in the browser.--browser-pipe(Internal use.) Proxy input and output, usually over an
sshconnection.
Window specifier option ¶
Certain commands affect an existing window. These take a window-specifier option that can specify which window(s) should be acted on. For example, to minimize windows 2 and 3 do:
domterm -w 2,3 minimize
-w window-specifier--window window-specifier--window=window-specifierSpecify which windows are affected by the current command.
The general format for window specifiers is here.
Miscellaneous commands ¶
help[sub-help] ¶Print some help. The sub-help may be a sub-command.
is-domterm¶Succeeds (exits with code 0) if the current terminal is DomTerm; fails (exits with code -1) otherwise.
This test does not depend on environment variables, but instead sends a special request code, and checks the response. This test works over an
sshconnection. (The test does require that eitherDOMTERMbe non-empty, or thatTERMbe either empty or contain the stringxterm; otherwise it does not try to the request code.)status[--verbose] [--by-session] ¶-
Prints various bits of information about the backend, sessions, windows, and version numbers. The information displayed and the format are likely to change. The default groups sessions by top-level window; the
--by-sessiongroups windows by session. The--verboseoption adds more detail. settingsname=value ... ¶Change the given local settings for the specified window(s).
If the value is empty, the local setting with the given name is removed, so the global setting (if set) becomes active.
browseurl ¶Create a new browser window or sub-window that displays url. This is implemented using an
iframe. Access depends on the permissions of the browser (front-end). (A future command may proxy via the back-end server.)One use for this is to view documentation in a sub-window:
$ domterm --above browse http://example.com/
view-savedfilename ¶The filename is an HTML file of a previously saved session. Open the session is “view” mode: Lines will be re-wrapped on window re-size, links are clickable, and hide/show buttons work.
kill-server[--only] ¶Kill the
domtermserver. This also kills all local sessions. Also close any windows, unless--onlyis specified. (This may kill remote sessions if their only window is closed.)
“Printing” images or html ¶
-
html[--base=base-url] ¶ html[--base=base-url] html-value ...hcat[--base=base-url] filename.html...-
Use this to embed HTML content info the DomTerm page. If there are no arguments, read from standard input. Either of the following work:
echo 'E = mc<sup>2</sup>' | domterm html domterm html 'E = mc<sup>2</sup>'
displays:
E = mc2.The html-value can be a complete html file, but elements such as
<html>,<body>or<style>are ignored.Relative URLs are resolved relative to the base-url, which can be an absolute URL or a filename or directory; the default is the current working directory.
The
hcatcommand takes the name of an html file, rather than literal html. (With no argumentshcatis the same ashtml.) The following are equivalent:domterm hcat /path/to/doc.html cat /path/to/doc.html | domterm html --base=/path/to/
-
image[-n] [--attrname=attrvalue]... filename ¶ imgcat[-n] [--attrname=attrvalue]... filenameimage[-n] [--attrname=attrvalue]... url-
This script “prints” the contents of the image file to domterm. The image must be of a type that can be displayed by an HTML
<img>element, such as apng,jpg, orsvgfile.If a filename is specified, the file is read by the domterm command, and sent to the front-end (using a “
data:” URI), so it works for remote contections. As the image data is “inline” in the DOM it is included when saving as HTML.If a url is specified, it is used instead. The front-end is responsible for fetching the data.
By default (no
-nis specified), the image has adisplay: blockstyle (so it is automatically on a “line” by itself),’ and gets a horizontal scroll bar if and only if it is too wide to fit. If-nis specified, then only a plain<img>element is written, which means you can write multiple images and other HTML on the same “line”.--attrname=attrvalueSpecify the given attribute; for example:
--height=200. Valid attrnames are the following, which are specified in the HTML specification:alt,longdesc,height,width,border,hspace,vspace,class.For example:
--width=600scales the image width to be the given number of pixels (in the CSS meaning). (The height is scaled proportionally, unless you also specify the--heightoption.)
fresh-line¶If not already at beginning of line, starts a fresh line
Sessions ¶
attachsession-specifier ¶Create a new window displaying an existing session. The same session (process) may be displayed in multiple windows. See session-specifier.
list¶List information about running sessions.
The
statuscommand shows more information, including some information about each window.
Windows operations ¶
close¶Close specified window(s), as if you clicked on the “close” button. The default windows-specifier is
.(the current window).detach¶Close specified window(s) (the default is
.), and (assuming there are no more windows attached to the session) make the session detached.minimize¶(Electron, Qt, and Wry only.) Minimize (iconify) the specified top-level windows, where the default window is
top. The minimized windows may be still visible in the task bar, as an icon on the desktop, or during an “windows expose” operationhide¶(Electron, Qt, and Wry only.) Hide the specified top-level windows. The hidden windows are not visible in the task bar, as icons on the desktop, or during an “windows expose” operation
show¶(Electron, Qt, and Wry only.) Show the specified minimized or hidden windows. If there are no windows, create one.
toggle-minimize¶(Electron, Qt, and Wry only.) Toggle between normal and minimized state: If a window is hidden or minimized, show it. If visible, minimize it. If there are no windows, create one.
toggle-hide¶(Electron, Qt, and Wry only.) Toggle between normal and hidden state: If a window is hidden or minimized, show it. If visible, hide it. If there are no windows, create one.
set-window-namename ¶Set name as the window-name of the specified window(s).
windowwindow-specifier ... subcommand options ... ¶Do the subcommand on the windows specified by the window-specifier list. Older (deprecated) form equivalent to:
--window=window-specifier ... subcommand options ...
Automation ¶
The following are useful for automatically or remotely controlling DomTerm.
For examples for doing automatic testing for DomTerm
check the file tests/Makefile.am in the sources.
do-keys[option|string]... ¶Simulate user keystrokes by sending them to the front-end for interpretation.
-wwindow-specifierIf specified, must be the first argument. Same as if specified before the
do-keysargument.-NcountRepeat following actions count times, until the next
-N.-ltext-etextSend the text as plain characters, with no interpretation for special key-bindings. Acts like a key-press event for each character. If
-e(“escape”) is used, string escapes are processed; if-l(“literal”) is used, the text is used as-is.-C[response]Wait until connection is closed. Only a single window is allowed in this case. Similar to a separate
domterm await --close [response]command, but avoids a race condition.- key-stroke
The front-end simulates the specified key-stroke, as a key-down event. Examples are
EnterorCtrl+A. (Ctrl-Ais accepted in addition to the modernCtrl+Astyle.) However, if the key-stroke starts and ends with single-quote, the characters between the quotes are processed as if with the-loptions. Also, if the key-stroke has no action in the current context, the front-end treats the key-stroke as if preceeded by-l
send-inputsend-option... string... ¶Send the specified string directly to the standard input of a session. If there is more than one string, send them in order, with a single space in between.
A string may have string escapes.
Usually
send-input "text"has the same effect asdo-keys -e "text". However,send-inputfeeds thetextdirectly to the application input, whiledo-keyssends it to the front-end for processing first. If the browser is in line-edit mode, it inserts thetextinput the editing area instead of sending it to the application.A send-option can be:
-ssession-specifierSend to the session as specified by the session-specifier.
-wwindow-specifierSend to the session attached to the specified window.
-C[response]Wait until connection is closed. Only a single window is allowed in this case. Similar to a separate
domterm await --close [response]command, but avoids a race condition.
capturecapture-option... ¶Get the text contents of the specified window (defaulting
., the current window). The text is printed on standard output. This command is useful for testing.A capture-options can be:
-BOnly capture the contents of the current buffer, as opposed to that of all buffers of the specified window.
-SOnly capture the contents of the selection.
-lInclude active soft newlines (i.e. from line-wrap or pretty-printing) as newlines in the output. Also skips extra whitespace (
" \t\r") at end of lines, and extra newlines at the end.-TPreserve tabs, if possible. When DomTerm receives a Tab character, it will remember that (assuming the columns moved past by the Tab contain just spaces). The
-Tflag will report a Tab character in the captured output; the default is to report the equivalent number of spaces.-eInclude ANSI escape sequences that encode color and style in the output. These escapes should work on almost all modern terminals. DomTerm-specific “logical” styles (such as prompt or input areas) are currently ignored.
-wwindow-specifierSame as if specified before the
capturecommand name.
In the future some options make be extended to take optional arguments, so scripts should not combine options: instead of
-Blewrite-B -l -e.awaitoptions... event... ¶Wait until one of the specifed events happen.
The following options and events are supported:
--match-outputpattern response [nlines]After each “block” of output, try match pattern (a regular expression) against the last nlines (default 1) lines of the buffers. (Trailing empty lines are not included in the nlines count.) If the match succeds, write response to standard output. (A newline is added if response is non-empty and does not end in a newline.)
When this test is run depends on buffering (how the application and network/system break output into blocks), so this test is mainly intended to detect when output is “done” and the application is waiting for input. Typically, the pattern would look for a prompt string.
--close[response]Wait until connection is closed. (This action is handled in the server, rather than the front-end.)
--timeouttime responseIf after time seconds none of the other events have occurred, return (with a non-zero exit code indicating failure). If response is non-empty, write it (plus a newline) to standard error.
-wwindow-specifierA window specifier for the affected window.
Miscellaneous options ¶
An argument that contains equal-sign (=),
does not start with a hyphen (-), and
precedes a command (if any) is
a settings option.
--geometrysize-and-positionSpecify the initial size and/or position of a new top-level window. See geometry specifier.
--namewindow-nameIf this command creates a new window, set window-name as its name.
--versionPrint version information and copyright, and then exit.
--verbosePrint information about interesting events. This works best with
--no-daemonize. A second--verboseprints more information.A single (respectively double)
--verboseprints the same as-d 7(respectively-d 15), but the latter prints a timestamp on each line.-ddebug-levelFiner-grained control over debugging level than using
--verbose, plus prints time-stamps before each message. Sets the debug-level as defined by the LWS logging API.-Lsocket-name--socket-name=socket-nameDomTerm uses a Unix Domain socket to communicate between the command-line and the server. By default the socket is the file
$XDG_RUNTIME_DIR/domterm/default.socket, but this option overrides that. Using different socket names mean you get different servers that do not know about each other. If socket-name starts with ‘/’ then the filename is absolute; otherwise$XDG_RUNTIME_DIR/domterm/is prepended. If there is no file extension,.socketis appended.DomTerm also creates a temporary
htmlthat has the same name as the socket, but with a.htmlextension. That is by default it is$XDG_RUNTIME_DIR/domterm/default.html.--settings=filename-
Specify the location of the Settings file containing user preferences. (The default is
.config/domterm/settings.iniin the user’s home directory, except on WSL (Windows Subsystem for Linux).)Note this flag won’t have much if any effect if you specify it when there is already a running domterm server.
--no-daemonizeWhen a domterm backend (server) is created, it normally turns itself into a daemon. This option prevents “daemonizing” - which is helpful for debugging.
--remote-debugging-port=debug-portOnly relevant for the
qtdomtermfront-end. (For the Electron front-end, use menu item Toggle Developer Tools. If using a general web browser, use its debugger.) Allow remote debugging (using a Chromium-based browser, such as Google Chrome). This is useful for debugging DomTerm itself, as well as any inspecting any unusual HTML, CSS, or JavaScript you might throw at it.
There are other ldomterm options which useful
if you want to run DomTerm as a server.
Starting a web server ¶
The domterm command normally starts an internal web-server, bur
for security reasons this is only usable by the current user on the
current computer (enforced by the browser having to read a file
in the user’s directory).
Sometimes you want a public web-server that other people can
attach to. For that use the --port option
and the --ssl options.
See Remote serving for more information.
--portportnumStart a server, listening on the specified portnum. A portnum of 0 lets the system choose an available port, which is printed out. The server is an
httpserver, unless--sslis specified, in which case it anhttpsserver. No front-end is started.--sslStart an
httpsserver rather than anhttpserver. Strongly recommended except for testing.--ssl-certcert-fileThe name of a file containing the server certificate.
--ssl-keykey-fileThe name of a file containing the passphrase needed for the private key.
--ssl-caca-fileCA (certificate authority) filepath.
--once(Probably obsolete.) Only allow a single connect before shutting down. This option is the default unless
--portis specified.
Working with styles ¶
All of these work with a window-specifier option,
defaulting to ., the current window.
reverse-videoon|off¶
add-stylestyle-rule ... ¶-
If called for the first time, create and install a temporary stylesheet. This temporary stylesheet has a
nameattribute with the value"(temporary-styles)". Add each style-rule to the temporary stylesheet.For example, to change the background color to pink:
$ domterm add-style "div.domterm { --background-color: pink }"You can also set the
background-colorstyle directly:$ domterm add-style "div.domterm { background-color: pink }"However, it is better to set the
--background-colorCSS variable, as that is required for reverse video and “Background Color Erase” to work.Inverse video (using CSS variables):
$ domterm add-style "div.domterm { --background-color: black; --foreground-color: white }"Changing font size:
$ domterm add-style "body { font-size: 14pt }" list-stylesheets¶List on the standard output the set of stylesheets associated with the domterm document, one per line:
$ domterm list-stylesheets 0: enabled - "style/domterm-core.css" 1: enabled - "style/domterm-standard.css" 2: enabled "Default DomTerm styling" "style/domterm-default.css" 3: enabled - "(temporary-styles)"
After the sequence number, either
enabledordisabledspecified whether the stylesheet is disabled. If the stylesheet has atitle, if is shown next (in json format); otherwise-is printed. If the stylesheet has thehrefattribute, it is shown next (in json format); otherwise, if it has thecodeattribute, that is shown; otherwise-is printed.load-stylesheetname filename-
Replace or create a new stylesheet with the given name. The content of the stylesheet are read from the given filename. If the filename is
-then standard input is used.The name is used to set the non-standard
nameattribute of the created<style>element. If there is an existing stylesheet with a matchingnameattribute, then that stylesheet is replaced; otherwise a new stylesheet is created. The name attribute is displayed by thelist-stylesheetssubcommand. print-stylesheetindex ¶Print out the style rules of the specified stylesheet, which is an index in the
list-stylesheetsoutput.-
disable-stylesheetindex ¶ enable-stylesheetindexDisable or enable the specified stylesheet. A index is an integer index into the list as shown by
list-stylesheets.$ domterm disable-stylesheet 2
