# tmux.Session.Run

- **Module:** tmux.Session
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/session_run.go#L77
- **Page:** https://libtmux.org/en/go/latest/reference/tmux-session-run/

```
tmux.Session.Run(ctx: context.Context, command: string, options: RunOptions) -> (RunResult, error)
```

Run starts command in a new window of this session, waits for it to finish, and reports its exit status and what its terminal showed. It is [os/exec] for a program that needs a terminal: the command runs with a tty, so it sees isatty, colour, and a width, and what comes back is the screen tmux rendered rather than the bytes the program wrote.

A nonzero status is a result, not an error; the error reports what tmux
could not do. The wait is tmux's own signal, backed by a liveness check that
widens from a quarter second in case that signal is lost: it needs no tmux
binary on the command's PATH and returns as the process exits. A command that never
exits holds Run until ctx ends. On error, Run removes its window regardless
of [RunOptions.Keep], since Run gives the caller no other chance to retry or
clean up; a bare [Session.Start] followed by [Running.Wait] leaves that
choice to the caller instead. [Server.RunShell] runs a command with no pane
at all.
