File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ def new_window(
202202 attach : bool = True ,
203203 window_index : str = "" ,
204204 window_shell : t .Optional [str ] = None ,
205+ environment : t .Optional [t .Dict [str , str ]] = None ,
205206 ) -> Window :
206207 """
207208 Return :class:`Window` from ``$ tmux new-window``.
@@ -259,6 +260,10 @@ def new_window(
259260 % (self .id , window_index ),
260261 )
261262
263+ if environment :
264+ for k , v in environment .items ():
265+ window_args += ("-e%s=%s" % (k , v ),)
266+
262267 if window_shell :
263268 window_args += (window_shell ,)
264269
Original file line number Diff line number Diff line change @@ -257,3 +257,16 @@ def test_cmd_inserts_sesion_id(session: Session) -> None:
257257 assert "-t" in cmd .cmd
258258 assert current_session_id in cmd .cmd
259259 assert cmd .cmd [- 1 ] == last_arg
260+
261+
262+ def test_new_window_with_environment (session : Session ) -> None :
263+ window = session .new_window (
264+ attach = True ,
265+ window_name = "window_with_environment" ,
266+ window_shell = "/usr/bin/env PS1='$ ' bash --norc --noprofile" ,
267+ environment = {"ENV_VAR" : "window" },
268+ )
269+ pane = window .attached_pane
270+ assert pane is not None
271+ pane .send_keys ("echo $ENV_VAR" )
272+ assert pane .capture_pane () == ["$ echo $ENV_VAR" , "window" , "$" ]
You can’t perform that action at this time.
0 commit comments