File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -442,6 +442,7 @@ def split_window(
442
442
vertical : bool = True ,
443
443
shell : t .Optional [str ] = None ,
444
444
percent : t .Optional [int ] = None ,
445
+ environment : t .Optional [dict [str , str ]] = None ,
445
446
) -> Pane :
446
447
"""
447
448
Split window and return the created :class:`Pane`.
@@ -520,6 +521,10 @@ def split_window(
520
521
if not attach :
521
522
tmux_args += ("-d" ,)
522
523
524
+ if environment :
525
+ for k , v in environment .items ():
526
+ tmux_args += ("-e%s=%s" % (k , v ),)
527
+
523
528
if shell :
524
529
tmux_args += (shell ,)
525
530
Original file line number Diff line number Diff line change 1
1
"""Test for libtmux Window object."""
2
2
import logging
3
+ import time
3
4
import typing as t
4
5
5
6
import pytest
@@ -310,3 +311,16 @@ def test_empty_window_name(session: Session) -> None:
310
311
"#{==:#{session_name}," + session .name + "}" ,
311
312
)
312
313
assert "''" in cmd .stdout
314
+
315
+
316
+ def test_split_window_with_environment (session : Session ) -> None :
317
+ window = session .new_window (window_name = "split_window_with_environment" )
318
+ pane = window .split_window (
319
+ shell = "/usr/bin/env PS1='$ ' bash --norc --noprofile" ,
320
+ environment = {"ENV_VAR" : "pane" },
321
+ )
322
+ assert pane is not None
323
+ # wait a bit for the prompt to be ready as the test gets flaky otherwise
324
+ time .sleep (0.05 )
325
+ pane .send_keys ("echo $ENV_VAR" )
326
+ assert pane .capture_pane () == ["$ echo $ENV_VAR" , "pane" , "$" ]
You can’t perform that action at this time.
0 commit comments