# Getting started

Source: https://libtmux.org/en/rs/latest/guides/getting-started/

> Run a complete program with this language library.

Use `libtmux` to create sessions, send input and read pane output from Rust.
The [complete capture program](https://libtmux.org/en/rs/latest/examples/capture-pane-output/) includes
imports, its entry point, project files, dependency setup and a run command.

## Run the smallest thing that proves it works

Open that example in an empty directory and save the files using their displayed
names. Its setup pins the library revision that was used to execute the program.
It needs tmux on `PATH` and the native tools named on the example page.

The program creates a private server, sends a command, waits for the complete
line `libtmux capture ready`, then cleans up. A timeout or command failure is
reported. It does not need an existing tmux session.

## What just happened

[`Pane::capture`](<https://libtmux.org/en/rs/latest/reference/pane-pane-capture/>) reads the visible screen. The complete program compares the
returned line bytes with the expected output and uses [`tokio::time::timeout`](https://docs.rs/tokio/latest/tokio/time/fn.timeout.html)
to bound the task. It kills its private server and shuts down the client before
returning a capture error.

## Connect to an existing server

Use the [complete attach program](https://libtmux.org/en/rs/latest/guides/attaching-to-tmux/) to select an existing
socket and find the `work` session. That example leaves tmux running; its
launcher owns setup and cleanup for trying it safely.

## Where to go next

[Sending keys](https://libtmux.org/en/rs/latest/guides/sending-keys/) explains input, and
[Capturing output](https://libtmux.org/en/rs/latest/guides/capturing-output/) explains completion.
[Querying and filtering](https://libtmux.org/en/rs/latest/guides/querying-and-filtering/) selects a target.
