Core LibraryTopics

Choose documentation 3

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Edit this page on GitHub

Pane interaction

Send input to a pane and capture its screen to interact with a running program. Attach and send keys provides examples. Sending keys and Capturing output are task guides; this page covers input defaults, capture ranges, and completion handling.

Typing into a pane

Two questions come up every time you send something to a pane: should tmux press Enter afterward, and should tmux interpret what you sent as key names (Enter, C-c) rather than literal characters? Choose both explicitly when a command depends on them.

Type without Enter: SendKeysAsync(new SendKeysRequest(text, enter: false))

Type + Enter (default): SendTextAsync(text) (defaults enter: true)

How "literal" is chosen: SendKeysRequest.Literal field; SendTextAsync hardcodes it

Examples

Text and Enter can be separate tmux commands. If the second operation fails, the text may already be in the pane. Check the current state before retrying; repeating the whole request can duplicate input.

Send a command line and press Enter:

await pane.SendKeysAsync(new SendKeysRequest("echo hi", enter: false));
await pane.SendTextAsync("echo hi"); // defaults enter: true

Reading a pane back

Capture reads the pane's visible screen by default. Request scrollback when you need earlier output. A capture is a snapshot of terminal contents, including any input echoed by the application.

await pane.CaptureAsync();

Waiting for something to finish

A send call completes when input reaches tmux. It does not wait for the shell command to finish. Wait for expected output or a completion signal.

Use TmuxWaitChannel when the command can signal a named tmux wait-for channel. Use a cancellation token to bound the wait.

Capture pane output shows capture and waiting examples. Waiting and retrying explains completion conditions and timeouts.

tmux manual and source

The tmux manual defines key-name and literal input and screen and history capture. A send operation delivers input; it does not establish the program's exit status.

Esc

Type to search.