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(
442442 vertical : bool = True ,
443443 shell : t .Optional [str ] = None ,
444444 percent : t .Optional [int ] = None ,
445+ environment : t .Optional [dict [str , str ]] = None ,
445446 ) -> Pane :
446447 """
447448 Split window and return the created :class:`Pane`.
@@ -520,6 +521,10 @@ def split_window(
520521 if not attach :
521522 tmux_args += ("-d" ,)
522523
524+ if environment :
525+ for k , v in environment .items ():
526+ tmux_args += ("-e%s=%s" % (k , v ),)
527+
523528 if shell :
524529 tmux_args += (shell ,)
525530
Original file line number Diff line number Diff line change 11"""Test for libtmux Window object."""
22import logging
3+ import time
34import typing as t
45
56import pytest
@@ -310,3 +311,16 @@ def test_empty_window_name(session: Session) -> None:
310311 "#{==:#{session_name}," + session .name + "}" ,
311312 )
312313 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