# pane.Pane.waitForCommand

- **Module:** pane
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/ad09eaef7ffff40f510989ee0695852c44a31576/packages/libtmux/src/pane.ts#L404
- **Page:** https://libtmux.org/en/ts/latest/reference/pane-pane-waitforcommand/

```
waitForCommand(
  options?: CommandWaitOptions,
): Promise<number>
```

Resolve with the exit status of the next command this pane's shell finishes.

Needs a shell that marks each command's end with OSC 133 (`ESC ] 133 ; D ; `[`status`](/en/ts/latest/reference/common-commandoutcome-status/)) from its prompt; tmux turns the mark into a
[`pane`](/en/ts/latest/reference/client-client-pane/)`-`[`command`](/en/ts/latest/reference/types-menuentry-command/)`-finished` event. [`send`](/en/ts/latest/reference/types-commandwaitoptions-send/) types a command line once the wait
is listening, so a command that ends at once is not missed. A shell's
first prompt marks an end too, before any command ran, so a wait armed
while the shell starts can resolve with 0. A shell without the marks never
resolves this: give it a `timeoutMs`, whose [`WaitTimeoutError`](/en/ts/latest/reference/errors-waittimeouterror/) names
the marks as the likely cause. A pane whose program has exited
rejects with [`LibTmuxError`](/en/ts/latest/reference/errors-libtmuxerror/). The mark carries a status alone; what
the command printed is on the pane, for [`Pane.capture`](/en/ts/latest/reference/pane-pane-capture/).

Requires tmux 3.8 or newer.

## Examples

```ts
const status = await pane.waitForCommand({ send: "make test", timeoutMs: 600_000 });
status; // 0 when the tests passed
```

## Parameters

- `options?` (`CommandWaitOptions`)
