# types.SpawnOptions

- **Module:** types
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** interface
- **Source:** https://github.com/libtmux/libtmux-ts/blob/ad09eaef7ffff40f510989ee0695852c44a31576/packages/libtmux/src/types.ts#L514
- **Page:** https://libtmux.org/en/ts/latest/reference/types-spawnoptions/

Where a program started by [`Server.spawn`](/en/ts/latest/reference/server-server-spawn/) runs, and what it gets.

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 the `PATH` of the client that asked for it, which
is this process's, or [`ServerOptions.environment`](/en/ts/latest/reference/server-serveroptions-environment/)'s when that is set. stderr shares the screen with stdout, and without
[`input`](/en/ts/latest/reference/types-spawnoptions-input/) the terminal is its stdin, so a program that pages or prompts
(`git log`, `sudo`) waits for keys as it would in a terminal.

## Members

### Other members

- [`environment`](/en/ts/latest/reference/types-spawnoptions-environment/) (property): Variables added to the program's environment. They reach tmux as command arguments, which `ps` on this machine shows while the command runs; pass a secret through `input` instead. tmux replaces a `PATH` passed that way with its client's, so the wrapper sets this one itself before finding `argv[0]`.
- [`from`](/en/ts/latest/reference/types-spawnoptions-from/) (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`](/en/ts/latest/reference/types-spawnoptions-height/) (property): Terminal height in rows, for `"session"`. Defaults to tmux's `default-size`.
- [`historyLimit`](/en/ts/latest/reference/types-spawnoptions-historylimit/) (property): Lines of scrollback kept for {@link Program.output}, for `"session"`, up to tmux's 2147483647. Defaults to 100000; older lines are dropped, and {@link ProgramResult.lostStart} says so. It bounds the output too: at most this many rows plus the screen's, each `width` columns, the newest kept.
- [`input`](/en/ts/latest/reference/types-spawnoptions-input/) (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 `stream` does.
- [`keep`](/en/ts/latest/reference/types-spawnoptions-keep/) (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. {@link Program.kill} and `await using` still end a running program.
- [`maxStreamBytes`](/en/ts/latest/reference/types-spawnoptions-maxstreambytes/) (property): Stop the copy after this many bytes; {@link Program.stream} then yields them and throws {@link StreamLimitError}. The program runs on. No limit by default, and the temporary directory may be memory-backed.
- [`orphanAfterMs`](/en/ts/latest/reference/types-spawnoptions-orphanafterms/) (property): Have tmux end the program, and remove its pane unless `keep` is set, this many milliseconds after this process stops renewing a lease on it: after it exits or dies without {@link Program.kill}. A live process renews the lease every third of this period. At least 1000; 60000 by default. `null` takes 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 pass `null`, there.
- [`placement`](/en/ts/latest/reference/types-spawnoptions-placement/) (property): `"session"`, the default without `from`, is a detached session of the program's own. With `from`, `"window"`, the default, is a background window of that pane's session, and `"split"` splits that pane, leaving focus where it was.
- [`signal`](/en/ts/latest/reference/types-spawnoptions-signal/) (property): Stops setup: an abort before the program has started removes its pane and rejects with {@link TmuxTransportError} of kind `cancelled`, whose `delivery` is `not_started` if nothing was made and `indeterminate` if the program may have begun. Once {@link Server.spawn} has returned, the program is the caller's to end.
- [`startDirectory`](/en/ts/latest/reference/types-spawnoptions-startdirectory/) (property): Directory the program starts in, taken as a literal path. Defaults to this process's current directory, or the `from` pane's. One that cannot be entered means the program never runs: see {@link ProgramStartError}.
- [`stream`](/en/ts/latest/reference/types-spawnoptions-stream/) (property): Copy everything the program writes, so {@link Program.stream} can return all of it. Needs the tmux server on this machine: the copy is a file in this process's temporary directory.
- [`width`](/en/ts/latest/reference/types-spawnoptions-width/) (property): Terminal width in columns, for `"session"`. Defaults to tmux's `default-size`.
