File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,31 @@ $ pip install --user --upgrade --pre libtmux
1919
2020### Features
2121
22+ #### Context Managers for tmux Objects
23+
24+ Added context manager support for all main tmux objects:
25+
26+ - ` Server ` : Automatically kills the server when exiting the context
27+ - ` Session ` : Automatically kills the session when exiting the context
28+ - ` Window ` : Automatically kills the window when exiting the context
29+ - ` Pane ` : Automatically kills the pane when exiting the context
30+
31+ Example usage:
32+
33+ ``` python
34+ with Server() as server:
35+ with server.new_session() as session:
36+ with session.new_window() as window:
37+ with window.split() as pane:
38+ pane.send_keys(' echo "Hello"' )
39+ # Do work with the pane
40+ # Everything is cleaned up automatically when exiting contexts
41+ ```
42+
43+ This makes it easier to write clean, safe code that properly cleans up tmux resources.
44+
45+ #### Server Initialization Callbacks
46+
2247Server now accepts 2 new optional params, ` socket_name_factory ` and ` on_init ` callbacks (#565 ):
2348
2449- ` socket_name_factory ` : Callable that generates unique socket names for new servers
You can’t perform that action at this time.
0 commit comments