Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d1479a5
common(cmd) AsyncTmuxCmd
tony Nov 9, 2025
e55b39f
Server,Session,Window,Pane: Add `.acmd`
tony Nov 9, 2025
37aff3c
AsyncTmuxCmd: Updates for TmuxCmd
tony Nov 9, 2025
88163c2
fix(AsyncTmuxCmd): Handle text decoding manually for async subprocess
tony Nov 9, 2025
189b238
tests(async) Basic example
tony Nov 9, 2025
b8a91a7
py(deps[dev]) Add `pytest-asyncio`
tony Nov 9, 2025
d6860aa
test(async): Add Server.acmd() tests
tony Nov 9, 2025
91dde66
test(async): Add Session.acmd() tests
tony Nov 9, 2025
8dce51e
test(async): Add Window.acmd() and Pane.acmd() tests
tony Nov 9, 2025
113ae75
test(async): Add concurrent operations test
tony Nov 9, 2025
da19c03
test(async): Add error handling tests
tony Nov 9, 2025
320a3ec
test(async): Add integration test & use fixture cleanup
tony Nov 9, 2025
1585a58
style(test_async): Use set literal instead of tuple
tony Nov 9, 2025
1cfc53d
refactor(tests): Reorganize async tests into tests/asyncio/
tony Nov 9, 2025
091d677
feat(server): Add async wrapper methods ahas_session() and anew_sessi…
tony Nov 9, 2025
33ff3b0
test(server): Add comprehensive tests for async wrapper methods
tony Nov 9, 2025
b5ffc98
feat(session): Add async wrapper methods anew_window() and arename_se…
tony Nov 9, 2025
6f50176
test(session): Add comprehensive tests for async wrapper methods
tony Nov 9, 2025
5ade848
feat(window): Add async wrapper method akill()
tony Nov 9, 2025
6964238
test(window): Add comprehensive tests for akill() async wrapper
tony Nov 9, 2025
80964dc
docs(server): Add comprehensive docstrings for async methods
tony Nov 9, 2025
39c93f2
docs(server): Convert async examples to narrative code blocks
tony Nov 9, 2025
103fe95
docs(session,window): Add comprehensive docstrings for async methods
tony Nov 9, 2025
7451ae8
docs: Add comprehensive async documentation
tony Nov 9, 2025
331263f
docs: Add bidirectional linking from sync to async methods
tony Nov 9, 2025
26c0d20
docs: Restore executable async doctests using asyncio.run() pattern
tony Nov 9, 2025
2967bf4
feat: Add critical async pane methods (asend_keys, acapture_pane, asp…
tony Nov 9, 2025
19f8de5
test: Add comprehensive unit tests for async pane methods (16 tests)
tony Nov 10, 2025
516e196
test: Add integration tests for async pane workflows (3 tests)
tony Nov 10, 2025
25a3991
docs: Add bidirectional cross-references between sync and async pane …
tony Nov 10, 2025
428e635
docs: Additional asyncio docs
tony Nov 10, 2025
e99a5da
docs: tidy async docstrings and exports
tony Nov 9, 2025
8ee4d30
tests(asyncio): strengthen pane typing
tony Nov 9, 2025
085615f
tests(asyncio): add dataclasses for session typing
tony Nov 9, 2025
c188750
tests(asyncio): harden server typing
tony Nov 9, 2025
4b00f5a
tests(asyncio): structure integration helpers
tony Nov 9, 2025
7c0ed02
chore(rebase): restore imports lost during rebase onto post-v0.56.0 m…
tony May 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
409 changes: 199 additions & 210 deletions README.md

Large diffs are not rendered by default.

486 changes: 486 additions & 0 deletions docs/api/async.md

Large diffs are not rendered by default.

169 changes: 9 additions & 160 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,166 +4,15 @@

# API Reference

libtmux's public API mirrors tmux's object hierarchy:
`Server` → `Session` → `Window` → `Pane`

## What do you want to do?

::::{grid} 1 2 2 2
:gutter: 2

:::{grid-item-card} Find a session, window, or pane?
:link: libtmux.server
:link-type: doc
Use `server.sessions.get()`, `session.windows.get()`.
:::

:::{grid-item-card} Send commands or keys to a terminal?
:link: libtmux.pane
:link-type: doc
Use `pane.send_keys()` and `pane.enter()`.
:::

:::{grid-item-card} Capture output from a pane?
:link: libtmux.pane
:link-type: doc
Use `pane.capture_pane()`.
:::

:::{grid-item-card} Write tests against tmux?
:link: testing/index
:link-type: doc
Use the pytest plugin and test helpers.
:::

::::

## Core Objects

::::{grid} 1 1 2 2
:gutter: 2 2 3 3

:::{grid-item-card} Server
:link: libtmux.server
:link-type: doc
Entry point. Manages sessions and executes raw tmux commands.
:::

:::{grid-item-card} Session
:link: libtmux.session
:link-type: doc
Manages windows within a tmux session.
:::

:::{grid-item-card} Window
:link: libtmux.window
:link-type: doc
Manages panes, layouts, and window operations.
:::

:::{grid-item-card} Pane
:link: libtmux.pane
:link-type: doc
Terminal instance. Send keys and capture output.
:::

::::

## Supporting Modules

::::{grid} 1 2 3 3
:gutter: 2 2 3 3

:::{grid-item-card} Common
:link: libtmux.common
:link-type: doc
Base classes and command execution.
:::

:::{grid-item-card} Neo
:link: libtmux.neo
:link-type: doc
Dataclass-based query interface.
:::

:::{grid-item-card} Options
:link: libtmux.options
:link-type: doc
tmux option get/set.
:::

:::{grid-item-card} Hooks
:link: libtmux.hooks
:link-type: doc
tmux hook management.
:::

:::{grid-item-card} Constants
:link: libtmux.constants
:link-type: doc
Format strings and constants.
:::

:::{grid-item-card} Exceptions
:link: libtmux.exc
:link-type: doc
Exception hierarchy.
:::

::::

## Testing

::::{grid} 1 1 1 1
:gutter: 2

:::{grid-item-card} Testing Utilities
:link: testing/index
:link-type: doc
pytest plugin, fixtures, and test helpers for testing code that uses libtmux.
:::

::::

## API Policy and Guarantees

These documents define the project's promises about the public API.

::::{grid} 1 2 3 3
:gutter: 2

:::{grid-item-card} Public API
:link: ../project/public-api
:link-type: doc
What is and is not considered stable public API.
:::

:::{grid-item-card} Compatibility
:link: ../project/compatibility
:link-type: doc
Supported versions of Python and tmux.
:::

:::{grid-item-card} Deprecations
:link: ../project/deprecations
:link-type: doc
Active deprecations and migration guidance.
:::

::::

```{toctree}
:hidden:
:maxdepth: 1

Server <libtmux.server>
Session <libtmux.session>
Window <libtmux.window>
Pane <libtmux.pane>
Common <libtmux.common>
Neo <libtmux.neo>
Options <libtmux.options>
Hooks <libtmux.hooks>
Constants <libtmux.constants>
Exceptions <libtmux.exc>
properties
servers
sessions
windows
panes
async
constants
common
exceptions
```
11 changes: 11 additions & 0 deletions docs/api/libtmux.server.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

tmux initializes a server automatically on first running (e.g. executing `tmux`)

## Async Methods

Server provides async versions of key methods for use in async applications:

- {meth}`~Server.ahas_session` - Check if session exists asynchronously
- {meth}`~Server.anew_session` - Create new session asynchronously

See {ref}`async` for comprehensive async documentation.

## API Reference

```{eval-rst}
.. autoclass:: libtmux.Server
:members:
Expand Down
11 changes: 11 additions & 0 deletions docs/api/libtmux.session.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
- Contain {ref}`Windows` (which contain {ref}`Panes`)
- Identified by `$`, e.g. `$313`

## Async Methods

Session provides async versions of key methods for use in async applications:

- {meth}`~Session.anew_window` - Create new window asynchronously
- {meth}`~Session.arename_session` - Rename session asynchronously

See {ref}`async` for comprehensive async documentation.

## API Reference

```{eval-rst}
.. autoclass:: libtmux.Session
:members:
Expand Down
10 changes: 10 additions & 0 deletions docs/api/libtmux.window.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
- Contain {ref}`Panes`
- Identified by `@`, e.g. `@313`

## Async Methods

Window provides async versions of key methods for use in async applications:

- {meth}`~Window.akill` - Kill window asynchronously

See {ref}`async` for comprehensive async documentation.

## API Reference

```{module} libtmux
:no-index:
```
Expand Down
107 changes: 74 additions & 33 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from inside a live tmux session.

## Requirements

- [tmux] 3.2a or newer
- [tmux]
- [pip] - for this handbook's examples

[tmux]: https://tmux.github.io/
Expand Down Expand Up @@ -44,15 +44,10 @@ the 4th beta release of `1.10.0` before general availability.
- [pipx]\:

```console
$ pipx install \
--suffix=@next \
--pip-args '\--pre' \
--force \
'libtmux'
$ pipx install --suffix=@next 'libtmux' --pip-args '\--pre' --force
// Usage: libtmux@next [command]
```

Usage: `libtmux@next [command]`

- [uv tool install][uv-tools]\:

```console
Expand Down Expand Up @@ -82,10 +77,7 @@ via trunk (can break easily):
- [pipx]\:

```console
$ pipx install \
--suffix=@master \
--force \
'libtmux @ git+https://github.com/tmux-python/libtmux.git@master'
$ pipx install --suffix=@master 'libtmux @ git+https://github.com/tmux-python/libtmux.git@master' --force
```

- [uv]\:
Expand Down Expand Up @@ -137,7 +129,7 @@ $ ptpython
```

```{module} libtmux
:no-index:

```

First, we can grab a {class}`Server`.
Expand Down Expand Up @@ -449,37 +441,85 @@ automatically sent, the leading space character prevents adding it to the user's
shell history. Omitting `enter=false` means the default behavior (sending the
command) is done, without needing to use `pane.enter()` after.

## Working with options
## Async Support

libtmux provides a unified API for managing tmux options across Server, Session,
Window, and Pane objects.
For async applications, libtmux provides async versions of key methods using the 'a' prefix naming convention.

### Getting options
### Basic Async Usage

```python
>>> server.show_option('buffer-limit')
50
import asyncio
from libtmux import Server

>>> window.show_options() # doctest: +ELLIPSIS
{...}
```
async def main():
server = Server()

### Setting options
# Create session asynchronously
session = await server.anew_session(session_name="async_demo")

```python
>>> window.set_option('automatic-rename', False) # doctest: +ELLIPSIS
Window(@... ...)
# Create window asynchronously
window = await session.anew_window(window_name="async_window")

>>> window.show_option('automatic-rename')
False
# Check session exists
exists = await server.ahas_session("async_demo")
print(f"Session exists: {exists}") # True

>>> window.unset_option('automatic-rename') # doctest: +ELLIPSIS
Window(@... ...)
asyncio.run(main())
```

:::{seealso}
See {ref}`options-and-hooks` for more details on options and hooks.
:::
### Concurrent Operations

One of the key benefits of async methods is concurrent execution:

```python
import asyncio

async def setup_workspace():
server = Server()

# Create multiple sessions concurrently
frontend, backend, database = await asyncio.gather(
server.anew_session(
session_name="frontend",
start_directory="~/project/frontend"
),
server.anew_session(
session_name="backend",
start_directory="~/project/backend"
),
server.anew_session(
session_name="database",
start_directory="~/project/database"
),
)

# Set up windows in each session concurrently
await asyncio.gather(
frontend.anew_window(window_name="editor"),
frontend.anew_window(window_name="server"),
backend.anew_window(window_name="api"),
backend.anew_window(window_name="tests"),
)

return frontend, backend, database
```

### Available Async Methods

- {meth}`Server.ahas_session` - Check if session exists
- {meth}`Server.anew_session` - Create new session
- {meth}`Session.anew_window` - Create new window
- {meth}`Session.arename_session` - Rename session
- {meth}`Window.akill` - Kill window

### When to Use Async

Use async methods when:
- Your application uses asyncio
- You need to perform multiple tmux operations concurrently
- You're integrating with async frameworks (FastAPI, aiohttp, etc.)

For more details, see {ref}`async`.

## Final notes

Expand All @@ -499,3 +539,4 @@ and our [test suite] (see {ref}`development`.)

[workspacebuilder.py]: https://github.com/tmux-python/libtmux/blob/master/libtmux/workspacebuilder.py
[test suite]: https://github.com/tmux-python/libtmux/tree/master/tests
[ptpython]: https://github.com/prompt-toolkit/ptpython
Loading
Loading