1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
|
# Migration notes
Migration and deprecation notes for libtmux are here, see {ref}`changelog` as
well.
```{admonition} Welcome on board! 👋
1. 📌 For safety, **always** pin the package
2. 📖 Check the migration notes _(You are here)_
3. 📣 If you feel something got deprecated and it interrupted you - past, present, or future - voice your opinion on the [tracker].
We want to make libtmux fun, reliable, and useful for users.
API changes can be painful.
If we can do something to draw the sting, we'll do it. We're taking a balanced approach. That's why these notes are here!
(Please pin the package. 🙏)
[tracker]: https://github.com/tmux-python/libtmux/discussions
```
## Upcoming Release
_Detailed migration steps for the next version will be posted here._
<!-- To the maintainers and contributors: please add migration details for the upcoming release here -->
## libtmux 0.50.0: Unified Options and Hooks API (#516)
### New unified options API
All tmux objects (Server, Session, Window, Pane) now share a consistent options
interface through {class}`~libtmux.options.OptionsMixin`:
```python
# Get all options
session.show_options()
# Get a single option
session.show_option('base-index')
# Set an option
window.set_option('automatic-rename', True)
# Unset an option
window.unset_option('automatic-rename')
```
### New hooks API
All tmux objects now support hook management through
{class}`~libtmux.hooks.HooksMixin`:
```python
# Set a hook
session.set_hook('session-renamed', 'display-message "Renamed!"')
# Get hook value
session.show_hook('session-renamed')
# Get all hooks
session.show_hooks()
# Remove a hook
session.unset_hook('session-renamed')
```
### Deprecated Window methods
The following `Window` methods are deprecated and will be removed in a future
release:
| Deprecated | Replacement |
|------------|-------------|
| `Window.set_window_option()` | {meth}`Window.set_option() <libtmux.Window.set_option>` |
| `Window.show_window_option()` | {meth}`Window.show_option() <libtmux.Window.show_option>` |
| `Window.show_window_options()` | {meth}`Window.show_options() <libtmux.Window.show_options>` |
**Before (deprecated):**
```python
window.set_window_option('automatic-rename', 'on')
window.show_window_option('automatic-rename')
window.show_window_options()
```
**After (0.50.0+):**
```python
window.set_option('automatic-rename', True)
window.show_option('automatic-rename')
window.show_options()
```
### Deprecated `g` parameter
The `g` parameter for global options is deprecated in favor of `global_`:
**Before (deprecated):**
```python
session.show_option('status', g=True)
session.set_option('status', 'off', g=True)
```
**After (0.50.0+):**
```python
session.show_option('status', global_=True)
session.set_option('status', 'off', global_=True)
```
Using the old `g` parameter will emit a {class}`DeprecationWarning`.
## libtmux 0.46.0 (2025-02-25)
#### Imports removed from libtmux.test (#580)
Root-level of imports from `libtmux.test` are no longer possible.
```python
# Before 0.46.0
from libtmux.test import namer
```
```python
# From 0.46.0 onward
from libtmux.test.named import namer
```
Same thing with constants:
```python
# Before 0.46.0
from libtmux.test import (
RETRY_INTERVAL_SECONDS,
RETRY_TIMEOUT_SECONDS,
TEST_SESSION_PREFIX
)
```
```python
# From 0.46.0 onward
from libtmux.test.constants import (
RETRY_INTERVAL_SECONDS,
RETRY_TIMEOUT_SECONDS,
TEST_SESSION_PREFIX
)
```
## libtmux 0.45.0 (2025-02-23)
### Test helpers: Module moves
Test helper functionality has been split into focused modules (#578):
- `libtmux.test` module split into:
- `libtmux.test.constants`: Test-related constants (`TEST_SESSION_PREFIX`, etc.)
- `libtmux.test.environment`: Environment variable mocking
- `libtmux.test.random`: Random string generation utilities
- `libtmux.test.temporary`: Temporary session/window management
**Breaking**: Import paths have changed. Update imports:
```python
# Old (0.44.x and earlier)
from libtmux.test import (
TEST_SESSION_PREFIX,
get_test_session_name,
get_test_window_name,
namer,
temp_session,
temp_window,
EnvironmentVarGuard,
)
```
```python
# New (0.45.0+)
from libtmux.test.constants import TEST_SESSION_PREFIX
from libtmux.test.environment import EnvironmentVarGuard
from libtmux.test.random import get_test_session_name, get_test_window_name, namer
from libtmux.test.temporary import temp_session, temp_window
```
## 0.35.0: Commands require explicit targets (2024-03-17)
### Commands require explicit targets (#535)
- {meth}`Server.cmd()`, {meth}`Session.cmd()`, {meth}`Window.cmd()`, {meth}`Pane.cmd()` require passing `target` instead of `['-t', target]`, `['-tTargetName']`, etc. This change is to avoid issues mistakenly interpreting `-t` in other shell values as targets.
Before:
```python
session.cmd('send-keys', 'echo hello', '-t', '0')
```
With 0.35.0 and after:
```python
session.cmd('send-keys', 'echo hello', target='0')
```
## 0.33.0: Deprecations for splitting (2024-03-03)
### Deprecations (#532)
- `Window.split_window()` to {meth}`Window.split()`
- `Pane.split_window()` to {meth}`Pane.split()`
## 0.31.0: Renaming and command cleanup (2024-02-17)
### Cleanups (#527)
- Commands: Param change
{meth}`Server.cmd()`, {meth}`Session.cmd()`, {meth}`Window.cmd()`, {meth}`Pane.cmd()`
- Use `cmd: str` as first positional
- Removed unused keyword arguments `**kwargs`
### Renamings (#527)
- `Session.attached_window` renamed to {meth}`Session.active_window`
- `Session.attached_window` deprecated
- `Session.attached_pane` renamed to {meth}`Session.active_pane`
- `Session.attached_pane` deprecated
- `Window.attached_pane` renamed to {meth}`Window.active_pane`
- `Window.attached_pane` deprecated
## 0.28.0: Resizing and detached by default (2024-02-15)
#### Detach by default
- {meth}`Session.new_window()` + {meth}`Window.split_window()` no longer attaches by default (#523)
- 0.28.0 and greater: Defaults to `attach=False`.
- 0.27.1 and below: Defaults to `attach=True`.
For the old behavior in 0.28.0 and beyond, pass `attach=True` explicitly.
#### Resizing panes
- `Pane.resize_pane()` renamed to {meth}`Pane.resize()` (via #523)
This convention will be more consistent with {meth}`Window.resize()`.
- {meth}`Pane.resize_pane()`'s params changed (#523)
- No longer accepts `-U`, `-D`, `-L`, `-R` directly, instead accepts
{class}`~libtmux.constants.ResizeAdjustmentDirection` (see below).
- 0.27.1 and below: `pane.resize_pane("-D", 20)`, `pane.resize_pane("-R", 20)`
- 0.28.0 and beyond:
```python
from libtmux.constants import ResizeAdjustmentDirection
pane.resize_pane(adjustment_direction=ResizeAdjustmentDirection.Down, adjustment=25)
pane.resize_pane(
adjustment_direction=ResizeAdjustmentDirection.Right, adjustment=25
)
```
## 0.17.0: Simplified attributes (2022-12-26)
### Finding objects / relations
- 0.16 and below: `session._windows()`, `session.list_windows()`, etc.
0.17 and after: {attr}`session.windows <libtmux.Session.windows>`
- 0.16 and below: `session.find_where({'window_name': my_window})`
0.17 and after: {meth}`session.windows.get(window_name=my_window, default=None) <libtmux.Session.windows>`
- If not found and not `default`, raises {exc}`~libtmux._internal.query_list.ObjectDoesNotExist`
- If multiple objects found, raises {exc}`~libtmux._internal.query_list.MultipleObjectsReturned`
- 0.16 and below: `session.where({'window_name': my_window})`
0.17 and after: {meth}`session.windows.filter(window_name=my_window) <libtmux.Session.windows>`
### Accessing attributes
- 0.16 and below: `window['id']`
0.17 and after: `window.id`
- 0.16 and below: `window.get('id')`
0.17 and after: `window.id`
- 0.16 and below: `window.get('id', None)`
0.17 and after: `getattr(window, 'id', None)`
<!---
# vim: set filetype=markdown:
-->
|