|
29 | 29 | session_check_name,
|
30 | 30 | )
|
31 | 31 |
|
| 32 | +if t.TYPE_CHECKING: |
| 33 | + from typing_extensions import Literal, TypeAlias |
| 34 | + |
| 35 | + DashLiteral: TypeAlias = Literal["-"] |
| 36 | + |
32 | 37 | logger = logging.getLogger(__name__)
|
33 | 38 |
|
34 | 39 |
|
@@ -351,6 +356,8 @@ def new_session(
|
351 | 356 | start_directory: t.Optional[str] = None,
|
352 | 357 | window_name: t.Optional[str] = None,
|
353 | 358 | window_command: t.Optional[str] = None,
|
| 359 | + x: t.Optional[t.Union[int, "DashLiteral"]] = None, |
| 360 | + y: t.Optional[t.Union[int, "DashLiteral"]] = None, |
354 | 361 | *args: t.Any,
|
355 | 362 | **kwargs: t.Any,
|
356 | 363 | ) -> Session:
|
@@ -388,11 +395,17 @@ def new_session(
|
388 | 395 | ::
|
389 | 396 |
|
390 | 397 | $ tmux new-session -n <window_name>
|
391 |
| - window_command : str |
| 398 | + window_command : str, optional |
392 | 399 | execute a command on starting the session. The window will close
|
393 | 400 | when the command exits. NOTE: When this command exits the window
|
394 | 401 | will close. This feature is useful for long-running processes
|
395 | 402 | where the closing of the window upon completion is desired.
|
| 403 | + x : [int, str], optional |
| 404 | + Force the specified width instead of the tmux default for a |
| 405 | + dettached session |
| 406 | + y : [int, str], optional |
| 407 | + Force the specified height instead of the tmux default for a |
| 408 | + dettached session |
396 | 409 |
|
397 | 410 | Returns
|
398 | 411 | -------
|
@@ -455,10 +468,11 @@ def new_session(
|
455 | 468 | if window_name:
|
456 | 469 | tmux_args += ("-n", window_name)
|
457 | 470 |
|
458 |
| - # tmux 2.6 gives unattached sessions a tiny default area |
459 |
| - # no need send in -x/-y if they're in a client already, though |
460 |
| - if has_gte_version("2.6") and "TMUX" not in os.environ: |
461 |
| - tmux_args += ("-x", 800, "-y", 600) |
| 471 | + if x is not None: |
| 472 | + tmux_args += ("-x", x) |
| 473 | + |
| 474 | + if y is not None: |
| 475 | + tmux_args += ("-y", y) |
462 | 476 |
|
463 | 477 | if window_command:
|
464 | 478 | tmux_args += (window_command,)
|
|
0 commit comments