SpawnOptions
Where a program started by Server.spawn runs, and what it gets.
Source and package
- Qualified name
-
SpawnOptions - Module
- types
- Package
- libtmux
- Source
- packages/libtmux/src/types.ts
-
Description#
The program gets a pane of its own and a real terminal. It runs on the machine the tmux server is on, with the tmux server's environment, except
PATH: tmux gives a pane thePATHof the client that asked for it, which is this process's, orServerOptions.environment's when that is set. stderr shares the screen with stdout, and withoutinputthe terminal is its stdin, so a program that pages or prompts (git log,sudo) waits for keys as it would in a terminal.
Members13#
- environment: Readonly<Record<string, string>> property Variables added to the program's environment. They reach tmux as command arguments, which
pson this machine shows while the command runs; pass a secret throughinputinstead. tmux replaces aPATHpassed that way with its client's, so the wrapper sets this one itself before findingargv[0]. - from: Pane property The pane to run beside: the program starts in its current directory, in its session, with that session's tmux environment. Variables the pane's shell exported are not inherited; only typing into that shell reaches them.
- height: number property Terminal height in rows, for
"session". Defaults to tmux'sdefault-size. - historyLimit: number property Lines of scrollback kept for
Program.output, for"session", up to tmux's 2147483647. Defaults to 100000; older lines are dropped, andProgramResult.lostStartsays so. It bounds the output too: at most this many rows plus the screen's, eachwidthcolumns, the newest kept. - input: string | Uint8Array property The program's stdin, as bytes or UTF-8 text. It is written to a private file the program reads, so it passes through no shell or tmux command, and the terminal stays the program's output. Needs the tmux server on this machine, as
streamdoes. - keep: boolean property Leave the pane in place once the program has ended, showing its output, for a person to read; it is theirs to close. A kept split closes at the next key pressed in it.
Program.killandawait usingstill end a running program. - maxStreamBytes: number property Stop the copy after this many bytes;
Program.streamthen yields them and throwsStreamLimitError. The program runs on. No limit by default, and the temporary directory may be memory-backed. - orphanAfterMs: number | null property Have tmux end the program, and remove its pane unless
keepis set, this many milliseconds after this process stops renewing a lease on it: after it exits or dies withoutProgram.kill. A live process renews the lease every third of this period. At least 1000; 60000 by default.nulltakes no lease, for a program meant to outlive this process. Renewals run on the event loop, so a stall longer than this, such as a debugger paused at a breakpoint, ends the program too; raise it, or passnull, there. - placement: Program
Placement property"session", the default withoutfrom, is a detached session of the program's own. Withfrom,"window", the default, is a background window of that pane's session, and"split"splits that pane, leaving focus where it was. - signal: Abort
Like property Stops setup: an abort before the program has started removes its pane and rejects withTmuxTransportErrorof kindcancelled, whosedeliveryisnot_startedif nothing was made andindeterminateif the program may have begun. OnceServer.spawnhas returned, the program is the caller's to end. - startDirectory: string property Directory the program starts in, taken as a literal path. Defaults to this process's current directory, or the
frompane's. One that cannot be entered means the program never runs: seeProgramStartError. - stream: boolean property Copy everything the program writes, so
Program.streamcan return all of it. Needs the tmux server on this machine: the copy is a file in this process's temporary directory. - width: number property Terminal width in columns, for
"session". Defaults to tmux'sdefault-size.