# tmuxtest.ScriptedTmux

- **Module:** tmuxtest
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/tmuxtest/scripted.go#L48
- **Page:** https://libtmux.org/en/go/latest/reference/tmuxtest-scriptedtmux/

```
tmuxtest.ScriptedTmux(t: testing.TB, script: ScriptedCommand) -> string
```

ScriptedTmux writes an executable that answers tmux invocations from script and returns its absolute path, for [tmux.ServerOptions.Binary]. It is how a test drives code that uses this package without a tmux to drive:

server, err := tmux.NewServer(tmux.ServerOptions{
	Binary: tmuxtest.ScriptedTmux(t,
		tmuxtest.ScriptedCommand{Contains: []string{"-V"}, Stdout: "tmux 3.7\n"},
		tmuxtest.ScriptedCommand{
			Contains: []string{"kill-pane"},
			Stderr:   "can't find pane: %7\n",
			ExitCode: 1,
		},
	),
})

The executable is removed with the test. It answers commands only: opening a
control connection or a notification stream speaks tmux's control protocol,
which a script cannot, so code that opens one needs [NewServer] and a real
tmux.
