Skip to content

Pass start_directory to new_session when building a session #829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 1, 2022
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
3 changes: 2 additions & 1 deletion src/tmuxp/workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def build(self, session=None, append=False):
"start_directory"
]
session = self.server.new_session(
session_name=self.sconf["session_name"]
session_name=self.sconf["session_name"],
**new_session_kwargs,
)

assert self.sconf["session_name"] == session.name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
session_name: sample_start_dir_session_path
start_directory: '/usr'
windows:
- panes:
-
22 changes: 22 additions & 0 deletions tests/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,28 @@ def f():
assert retry_until(f)


@pytest.mark.skipif(
has_lt_version("3.2a"), reason="needs format introduced in tmux >= 3.2a"
)
def test_start_directory_sets_session_path(server):
yaml_config = test_utils.read_config_file(
"workspacebuilder/start_directory_session_path.yaml"
)
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)

builder = WorkspaceBuilder(sconf=sconfig, server=server)
builder.build()

session = builder.session
expected = "{0}|/usr".format(session.id)

cmd = server.cmd("list-sessions", "-F", "#{session_id}|#{session_path}")
assert expected in cmd.stdout


def test_pane_order(session):
"""Pane ordering based on position in config and ``pane_index``.

Expand Down