|
15 | 15 | import typing as t
|
16 | 16 | import warnings
|
17 | 17 |
|
| 18 | +from libtmux import exc, formats |
18 | 19 | from libtmux._internal.query_list import QueryList
|
| 20 | +from libtmux._internal.types import StrPath |
19 | 21 | from libtmux.common import tmux_cmd
|
20 | 22 | from libtmux.neo import fetch_objs
|
21 | 23 | from libtmux.pane import Pane
|
22 | 24 | from libtmux.session import Session
|
23 | 25 | from libtmux.window import Window
|
24 | 26 |
|
25 |
| -from . import exc, formats |
26 | 27 | from .common import (
|
27 | 28 | EnvironmentMixin,
|
28 | 29 | PaneDict,
|
@@ -431,7 +432,7 @@ def new_session(
|
431 | 432 | session_name: str | None = None,
|
432 | 433 | kill_session: bool = False,
|
433 | 434 | attach: bool = False,
|
434 |
| - start_directory: str | None = None, |
| 435 | + start_directory: StrPath | None = None, |
435 | 436 | window_name: str | None = None,
|
436 | 437 | window_command: str | None = None,
|
437 | 438 | x: int | DashLiteral | None = None,
|
@@ -466,7 +467,7 @@ def new_session(
|
466 | 467 | kill_session : bool, optional
|
467 | 468 | Kill current session if ``$ tmux has-session``.
|
468 | 469 | Useful for testing workspaces.
|
469 |
| - start_directory : str, optional |
| 470 | + start_directory : str or PathLike, optional |
470 | 471 | specifies the working directory in which the
|
471 | 472 | new session is created.
|
472 | 473 | window_name : str, optional
|
@@ -542,7 +543,9 @@ def new_session(
|
542 | 543 | tmux_args += ("-d",)
|
543 | 544 |
|
544 | 545 | if start_directory:
|
545 |
| - tmux_args += ("-c", start_directory) |
| 546 | + # as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-session -c. |
| 547 | + start_directory = pathlib.Path(start_directory).expanduser() |
| 548 | + tmux_args += ("-c", str(start_directory)) |
546 | 549 |
|
547 | 550 | if window_name:
|
548 | 551 | tmux_args += ("-n", window_name)
|
|
0 commit comments