Skip to content

Commit 3f1fe07

Browse files
committed
docs(CHANGES) Note context managers
1 parent 38e0bee commit 3f1fe07

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

CHANGES

+24-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,32 @@ $ pip install --user --upgrade --pre libtmux
1313

1414
<!-- To maintainers and contributors: Please add notes for the forthcoming version below -->
1515

16-
- _Future release notes will be placed here_
17-
1816
### Features
1917

18+
#### Context Managers for tmux Objects
19+
20+
Added context manager support for all main tmux objects:
21+
22+
- `Server`: Automatically kills the server when exiting the context
23+
- `Session`: Automatically kills the session when exiting the context
24+
- `Window`: Automatically kills the window when exiting the context
25+
- `Pane`: Automatically kills the pane when exiting the context
26+
27+
Example usage:
28+
```python
29+
with Server() as server:
30+
with server.new_session() as session:
31+
with session.new_window() as window:
32+
with window.split() as pane:
33+
pane.send_keys('echo "Hello"')
34+
# Do work with the pane
35+
# Everything is cleaned up automatically when exiting contexts
36+
```
37+
38+
This makes it easier to write clean, safe code that properly cleans up tmux resources.
39+
40+
#### Server Initialization Callbacks
41+
2042
Server now accepts 2 new optional params, `socket_name_factory` and `on_init` callbacks (#565):
2143

2244
- `socket_name_factory`: Callable that generates unique socket names for new servers

0 commit comments

Comments
 (0)