# pane.Pane.runCommand

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

```
runCommand(
  command: string,
  options?: ShellCommandOptions,
): Promise<ShellCommandResult>
```

Run one framed command in this pane's existing POSIX shell.

The command inherits the shell's directory, variables and functions.
It runs in a subshell, so changes leave the interactive shell where it was.
An exit status requires the command's own frame. A shell's OSC 133
completion is additional evidence while the observation is open.

Read `outcome` and [`outputComplete`](/en/ts/latest/reference/shell-command-shellcommandevidence-outputcomplete/) before using the bounded output.
Another writer can change shell state or print between the markers.
[`foreignOutputSuspected`](/en/ts/latest/reference/shell-command-shellcommandevidence-foreignoutputsuspected/) reports foreign framing when visible. A timeout
or cancellation stops waiting. The shell can still execute input that
tmux already accepted. Check `delivery` before sending another command.

## Parameters

- `command` (`string`)
- `options?` (`ShellCommandOptions`)

## Errors

- [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError): for an invalid command or deadline.
- [`LibTmuxError`](/en/ts/latest/reference/errors-libtmuxerror/): for an unsupported shell or synchronized pane.
- [`TmuxServerRestartedError`](/en/ts/latest/reference/errors-tmuxserverrestartederror/): if the handle's daemon has changed.
- [`TmuxCommandError`](/en/ts/latest/reference/errors-tmuxcommanderror/): if tmux refuses the dispatch.

## Examples

```ts
const session = await server.newSession({ shellCommand: "exec sh -i" });
const result = await session.activePane?.runCommand("printf 'hello'");
result?.output; // "hello"
```
