Skip to content

Commit 7998363

Browse files
committed
Server(feat[new_session]): Add StrPath type support for start_directory
why: Standardize path handling to accept both str and PathLike objects what: - Import StrPath from libtmux._internal.types - Update start_directory parameter type annotation to StrPath | None - Update docstring to reflect str or PathLike support - Maintain existing if start_directory: logic for proper command building
1 parent a3c0316 commit 7998363

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libtmux/server.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
import typing as t
1616
import warnings
1717

18+
from libtmux import exc, formats
1819
from libtmux._internal.query_list import QueryList
20+
from libtmux._internal.types import StrPath
1921
from libtmux.common import tmux_cmd
2022
from libtmux.neo import fetch_objs
2123
from libtmux.pane import Pane
2224
from libtmux.session import Session
2325
from libtmux.window import Window
2426

25-
from . import exc, formats
2627
from .common import (
2728
EnvironmentMixin,
2829
PaneDict,
@@ -431,7 +432,7 @@ def new_session(
431432
session_name: str | None = None,
432433
kill_session: bool = False,
433434
attach: bool = False,
434-
start_directory: str | None = None,
435+
start_directory: StrPath | None = None,
435436
window_name: str | None = None,
436437
window_command: str | None = None,
437438
x: int | DashLiteral | None = None,
@@ -466,7 +467,7 @@ def new_session(
466467
kill_session : bool, optional
467468
Kill current session if ``$ tmux has-session``.
468469
Useful for testing workspaces.
469-
start_directory : str, optional
470+
start_directory : str or PathLike, optional
470471
specifies the working directory in which the
471472
new session is created.
472473
window_name : str, optional
@@ -542,7 +543,9 @@ def new_session(
542543
tmux_args += ("-d",)
543544

544545
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))
546549

547550
if window_name:
548551
tmux_args += ("-n", window_name)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy