Skip to content

Commit addcf48

Browse files
committed
docs(README): Enhance project README with comprehensive overview
- Add Key Features section highlighting the library's capabilities - Add Use Cases section with real-world applications - Add Testing with pytest section with example code - Add Advanced Usage section covering context managers and advanced scripting - Improve overall structure and organization of the README - Add links to relevant documentation sections
1 parent 5e17fad commit addcf48

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

Diff for: README.md

+78
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ sessions, windows, and panes. Additionally, `libtmux` powers [tmuxp], a tmux wor
99
[![Code Coverage](https://codecov.io/gh/tmux-python/libtmux/branch/master/graph/badge.svg)](https://codecov.io/gh/tmux-python/libtmux)
1010
[![License](https://img.shields.io/github/license/tmux-python/libtmux.svg)](https://github.com/tmux-python/libtmux/blob/master/LICENSE)
1111

12+
## Key Features
13+
14+
- **Intuitive API**: Control tmux servers, sessions, windows, and panes with a clean, object-oriented interface
15+
- **Complete Automation**: Create and manage complex tmux environments programmatically
16+
- **Type Annotations**: Full typing support for modern Python development
17+
- **Pytest Plugin**: Built-in testing tools for tmux automation
18+
- **Context Managers**: Safe session and window management with Python's context protocol
19+
- **Robust Architecture**: Built on tmux's native concepts of targets and formats
20+
1221
libtmux builds upon tmux's
1322
[target](http://man.openbsd.org/OpenBSD-5.9/man1/tmux.1#COMMANDS) and
1423
[formats](http://man.openbsd.org/OpenBSD-5.9/man1/tmux.1#FORMATS) to
@@ -19,6 +28,17 @@ View the [documentation](https://libtmux.git-pull.com/),
1928
[API](https://libtmux.git-pull.com/api.html) information and
2029
[architectural details](https://libtmux.git-pull.com/about.html).
2130

31+
## Use Cases
32+
33+
- **Development Environment Automation**: Set up consistent workspaces across projects
34+
- **CI/CD Systems**: Create isolated environments for testing and deployment
35+
- **System Monitoring**: Build interactive dashboards for server administration
36+
- **Remote Pair Programming**: Facilitate collaborative development sessions
37+
- **Data Science Workflows**: Manage complex data processing pipelines
38+
- **Education and Demonstrations**: Create multi-window learning environments
39+
40+
For more detailed examples, see our [use cases documentation](https://libtmux.git-pull.com/topics/use_cases.html).
41+
2242
# Install
2343

2444
```console
@@ -246,6 +266,64 @@ Window(@1 1:..., Session($1 ...))
246266
Session($1 ...)
247267
```
248268

269+
# Testing with pytest
270+
271+
libtmux includes a pytest plugin that provides fixtures for testing tmux operations:
272+
273+
```python
274+
def test_session_creation(session):
275+
"""Test creating a new window in the session."""
276+
window = session.new_window(window_name="test_window")
277+
assert window.window_name == "test_window"
278+
279+
# Create a new pane
280+
pane = window.split_window()
281+
assert len(window.panes) == 2
282+
283+
# Send keys to the pane
284+
pane.send_keys("echo 'Hello from test'")
285+
```
286+
287+
See [pytest plugin documentation](https://libtmux.git-pull.com/pytest-plugin/index.html) for more details.
288+
289+
# Advanced Usage
290+
291+
libtmux supports a wide range of advanced use cases:
292+
293+
## Context Managers
294+
295+
Safely manage sessions and windows with Python's context protocol:
296+
297+
```python
298+
with Server().new_session(session_name="my_session") as session:
299+
window = session.new_window(window_name="my_window")
300+
# Work with the window...
301+
# Session is properly cleaned up when context exits
302+
```
303+
304+
## Advanced Scripting
305+
306+
Create complex window layouts and integrate with external systems:
307+
308+
```python
309+
session = server.new_session(session_name="dashboard")
310+
main = session.new_window(window_name="main")
311+
312+
# Create a grid layout with 4 panes
313+
top_left = main.attached_pane
314+
top_right = top_left.split_window(vertical=True)
315+
bottom_left = top_left.split_window(vertical=False)
316+
bottom_right = top_right.split_window(vertical=False)
317+
318+
# Configure each pane
319+
top_left.send_keys("htop", enter=True)
320+
top_right.send_keys("watch -n 1 df -h", enter=True)
321+
bottom_left.send_keys("tail -f /var/log/syslog", enter=True)
322+
bottom_right.send_keys("netstat -tunapl", enter=True)
323+
```
324+
325+
See [advanced scripting documentation](https://libtmux.git-pull.com/topics/advanced_scripting.html) for more examples.
326+
249327
# Python support
250328

251329
Unsupported / no security releases or bug fixes:

0 commit comments

Comments
 (0)