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(
202
202
attach : bool = True ,
203
203
window_index : str = "" ,
204
204
window_shell : t .Optional [str ] = None ,
205
+ environment : t .Optional [dict [str , str ]] = None ,
205
206
) -> Window :
206
207
"""
207
208
Return :class:`Window` from ``$ tmux new-window``.
@@ -259,6 +260,10 @@ def new_window(
259
260
% (self .id , window_index ),
260
261
)
261
262
263
+ if environment :
264
+ for k , v in environment .items ():
265
+ window_args += ("-e%s=%s" % (k , v ),)
266
+
262
267
if window_shell :
263
268
window_args += (window_shell ,)
264
269
Original file line number Diff line number Diff line change @@ -257,3 +257,16 @@ def test_cmd_inserts_sesion_id(session: Session) -> None:
257
257
assert "-t" in cmd .cmd
258
258
assert current_session_id in cmd .cmd
259
259
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