Skip to content

Commit c7ba64e

Browse files
committed
docs(README): add concepts, testing, and links
1 parent 096d59d commit c7ba64e

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,79 @@ right.send_keys("htop", enter=True)
8686
print(f"Attach with: tmux attach -t {session.name}")
8787
```
8888

89+
## Core concepts
90+
91+
| libtmux object | tmux concept | Notes |
92+
|----------------|-----------------------------|--------------------------------|
93+
| `Server` | tmux server / socket | Entry point; owns sessions |
94+
| `Session` | tmux session (`$0`, `$1`,...) | Owns windows |
95+
| `Window` | tmux window (`@1`, `@2`,...) | Owns panes |
96+
| `Pane` | tmux pane (`%1`, `%2`,...) | Where commands run |
97+
98+
Collections are live and queryable:
99+
100+
```python
101+
server = libtmux.Server()
102+
session = server.sessions.get(session_name="demo")
103+
api_windows = session.windows.filter(window_name__startswith="api")
104+
pane = session.active_window.active_pane
105+
pane.send_keys("echo 'hello from libtmux'", enter=True)
106+
```
107+
108+
## tmux vs libtmux vs tmuxp
109+
110+
| Tool | Layer | Typical use case |
111+
|---------|----------------------------|----------------------------------------------------|
112+
| tmux | CLI / terminal multiplexer | Everyday terminal usage, manual control |
113+
| libtmux | Python API over tmux | Programmatic control, automation, testing |
114+
| tmuxp | App on top of libtmux | Declarative tmux workspaces from YAML / TOML |
115+
116+
## Raw tmux when you need it
117+
118+
```python
119+
server = libtmux.Server(socket_name="libtmux_doctest")
120+
result = server.cmd("display-message", "hello world")
121+
print(result.stdout) # ['hello world']
122+
print(result.returncode) # 0 on success
123+
```
124+
125+
## Testing & fixtures
126+
127+
- pytest plugin provides fresh tmux server/session/window/pane fixtures
128+
- Temporary HOME and tmux config fixtures keep indices stable
129+
- `TestServer` helper spins up multiple isolated tmux servers
130+
- See the docs for full fixture list and usage examples
131+
132+
## When you might not need libtmux
133+
134+
- Layouts are static and live entirely in tmux config files
135+
- You do not need to introspect or control running tmux from other tools
136+
- Python is unavailable where tmux is running
137+
138+
## Project links
139+
140+
- Docs: [docs]
141+
- API reference: [api]
142+
- Changelog: [history]
143+
- Migration notes: [migration]
144+
- Issues: [issues]
145+
- Test coverage: [coverage]
146+
- Releases: [releases]
147+
- License: [license]
148+
- Support: [support]
149+
150+
## Contributing & support
151+
152+
Contributions are welcome. Please open an issue or PR if you find a bug or want to improve the API or docs. If libtmux helps you ship, consider sponsoring development via [support].
153+
154+
[docs]: https://libtmux.git-pull.com
155+
[api]: https://libtmux.git-pull.com/api.html
156+
[history]: https://libtmux.git-pull.com/history.html
157+
[migration]: https://libtmux.git-pull.com/migration.html
158+
[issues]: https://github.com/tmux-python/libtmux/issues
159+
[coverage]: https://codecov.io/gh/tmux-python/libtmux
160+
[releases]: https://pypi.org/project/libtmux/
161+
[license]: https://github.com/tmux-python/libtmux/blob/master/LICENSE
162+
[support]: https://tony.sh/support.html
89163
[tmuxp]: https://tmuxp.git-pull.com
90164
[tmux]: https://github.com/tmux/tmux

0 commit comments

Comments
 (0)