# pane.Pane.waitForCommand

- **Module:** pane
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/pane.ts#L405
- **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`) from its prompt; tmux turns the mark into a
`pane-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`)

## tmux command

The tmux commands behind `waitForCommand`.

- [`wait-for`](/en/tmux/latest/manual/wait-for/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_wait_for_entry`](/en/tmux/latest/reference/c-variable-cmd_wait_for_entry/) (attribute)
- [`cmd_wait_for_exec`](/en/tmux/latest/reference/c-function-cmd-wait-for-c-cmd_wait_for_exec/) (function)
