Skip to content

Commit ded89cd

Browse files
committed
docs(MIGRATION): Add migration notes for options/hooks API (#516)
why: Users upgrading to 0.50.0 need clear guidance on deprecated methods and the new unified options/hooks API. what: - Document new unified options API (show_options, show_option, set_option, unset_option) available on all tmux objects - Document new hooks API (set_hook, show_hook, show_hooks, unset_hook) - Add deprecation notes for Window.set_window_option(), Window.show_window_option(), Window.show_window_options() - Add deprecation notes for `g` parameter in favor of `global_` - Include before/after code examples for each migration
1 parent b92cc73 commit ded89cd

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

MIGRATION

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,93 @@ _Detailed migration steps for the next version will be posted here._
2525

2626
<!-- To the maintainers and contributors: please add migration details for the upcoming release here -->
2727

28+
## libtmux 0.50.0: Unified Options and Hooks API (#516)
29+
30+
### New unified options API
31+
32+
All tmux objects (Server, Session, Window, Pane) now share a consistent options
33+
interface through {class}`~libtmux.options.OptionsMixin`:
34+
35+
```python
36+
# Get all options
37+
session.show_options()
38+
39+
# Get a single option
40+
session.show_option('base-index')
41+
42+
# Set an option
43+
window.set_option('automatic-rename', True)
44+
45+
# Unset an option
46+
window.unset_option('automatic-rename')
47+
```
48+
49+
### New hooks API
50+
51+
All tmux objects now support hook management through
52+
{class}`~libtmux.hooks.HooksMixin`:
53+
54+
```python
55+
# Set a hook
56+
session.set_hook('session-renamed', 'display-message "Renamed!"')
57+
58+
# Get hook value
59+
session.show_hook('session-renamed')
60+
61+
# Get all hooks
62+
session.show_hooks()
63+
64+
# Remove a hook
65+
session.unset_hook('session-renamed')
66+
```
67+
68+
### Deprecated Window methods
69+
70+
The following `Window` methods are deprecated and will be removed in a future
71+
release:
72+
73+
| Deprecated | Replacement |
74+
|------------|-------------|
75+
| `Window.set_window_option()` | {meth}`Window.set_option() <libtmux.Window.set_option>` |
76+
| `Window.show_window_option()` | {meth}`Window.show_option() <libtmux.Window.show_option>` |
77+
| `Window.show_window_options()` | {meth}`Window.show_options() <libtmux.Window.show_options>` |
78+
79+
**Before (deprecated):**
80+
81+
```python
82+
window.set_window_option('automatic-rename', 'on')
83+
window.show_window_option('automatic-rename')
84+
window.show_window_options()
85+
```
86+
87+
**After (0.50.0+):**
88+
89+
```python
90+
window.set_option('automatic-rename', True)
91+
window.show_option('automatic-rename')
92+
window.show_options()
93+
```
94+
95+
### Deprecated `g` parameter
96+
97+
The `g` parameter for global options is deprecated in favor of `global_`:
98+
99+
**Before (deprecated):**
100+
101+
```python
102+
session.show_option('status', g=True)
103+
session.set_option('status', 'off', g=True)
104+
```
105+
106+
**After (0.50.0+):**
107+
108+
```python
109+
session.show_option('status', global_=True)
110+
session.set_option('status', 'off', global_=True)
111+
```
112+
113+
Using the old `g` parameter will emit a {class}`DeprecationWarning`.
114+
28115
## libtmux 0.46.0 (2025-02-25)
29116

30117
#### Imports removed from libtmux.test (#580)

0 commit comments

Comments
 (0)