Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
session_name: sampleconfig
windows:
- panes:
- start_directory: /usr
- start_directory: /etc
29 changes: 29 additions & 0 deletions tests/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,3 +1154,32 @@ def test_load_workspace_sleep(
time.sleep(0.1)
captured_pane = "\n".join(pane.capture_pane())
assert output in captured_pane


def test_first_pane_start_directory(session, tmp_path: pathlib.Path):
yaml_config = test_utils.read_config_file(
"workspacebuilder/first_pane_start_directory.yaml"
)

sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(str(yaml_config)).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)

builder = WorkspaceBuilder(sconf=sconfig)
builder.build(session=session)

assert session == builder.session
dirs = ["/usr", "/etc"]

assert session.windows
window = session.windows[0]
for path, p in zip(dirs, window.panes):

def f():
p.server._update_panes()
pane_path = p.current_path
return path in pane_path or pane_path == path

# handle case with OS X adding /private/ to /tmp/ paths
assert retry_until(f)
5 changes: 5 additions & 0 deletions tmuxp/workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def iter_create_windows(self, session, append=False):
else:
sd = None

# If the first pane specifies a start_directory, use that instead.
panes = wconf["panes"]
if panes and "start_directory" in panes[0]:
sd = panes[0]["start_directory"]

if "window_shell" in wconf:
ws = wconf["window_shell"]
else:
Expand Down