Skip to content

v0.44.0 - Context managers

Compare
Choose a tag to compare
@tony tony released this 16 Feb 22:24
· 110 commits to master since this release

What's Changed

Support for context managers

by @tony in #566.

Added context manager support for all main tmux objects:

  • Server: Automatically kills the server when exiting the context
  • Session: Automatically kills the session when exiting the context
  • Window: Automatically kills the window when exiting the context
  • Pane: Automatically kills the pane when exiting the context

Example usage:

with Server() as server:
    with server.new_session() as session:
        with session.new_window() as window:
            with window.split() as pane:
                pane.send_keys('echo "Hello"')
                # Do work with the pane
                # Everything is cleaned up automatically when exiting contexts

This makes it easier to write clean, safe code that properly cleans up tmux resources.

Full Changelog: v0.43.0...v0.44.0