# tmux.Running.StreamTo

- **Module:** tmux.Running
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/session_run.go#L540
- **Page:** https://libtmux.org/en/go/latest/reference/tmux-running-streamto/

```
tmux.Running.StreamTo(ctx: context.Context, destination: io.Writer) -> (RunResult, error)
```

StreamTo copies what the command prints into destination as it prints it and then reports how it ended, so following a command and collecting its outcome are one blocking call rather than a goroutine the caller writes. It returns exactly what [Running.Wait] returns and, like Wait, removes the window unless [RunOptions.Keep] was set. destination is written only by this call, so it needs no synchronization of its own, and [Running.Kill] may be called from another goroutine while it runs.

The stream is what tmux pushed, which is not quite everything: output the
command printed before StreamTo opened its observation may or may not be in
it, and tmux can drop a line printed with nothing between it and the
command's exit. [RunResult.Lines] is a screen capture rather than a
notification stream and remains the authoritative record of what the command
showed. Streaming needs a control client, which a [Connection]-bound value
does not have, so it returns [ErrConnectionRequiresProcess] there; Wait alone
does not.
