Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-go latest

Session.Run

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. That screen holds a bounded history; see RunResult.Lines. For a large output, have the command write it to a file, or follow it with Running.StreamTo.

Source and package
Qualified name
tmux.Session.Run
Package
tmux
Declared in
Session
Distribution
github.com/libtmux/libtmux-go/tmux
Source
tmux/session_run.go

Description#

tmux runs command as default-shell -c command, so it is written in the language of the session's default-shell option, which tmux takes from $SHELL when it starts the server: under fish, echo $((1+2)) is an error. For one language on every machine, set default-shell, or write the command as sh -c '...'.

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.

On a session bound to a Connection, Run works as it does elsewhere: the wait uses a control client of its own rather than a lane, so one lane is enough, and the final screen is read through a scratch tmux buffer and a temporary file that tmux writes and this process reads.

Guides#

Pages that discuss Run.

Esc

Type to search.

Reference previewOpen reference