Skip to content

Commit c80b2d1

Browse files
committed
wip: sort through conditional logic in builder / freezer.
1 parent 20029dc commit c80b2d1

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

tmuxp/workspacebuilder.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,14 @@ def freeze(session):
265265
wconf['layout'] = w.get('window_layout')
266266
wconf['panes'] = []
267267

268-
if (
269-
all(
270-
w.panes[0].get('pane_current_path') ==
271-
p.get('pane_current_path') for p in w.panes
272-
)
273-
):
268+
# If all panes have same path, set 'start_directory' instead
269+
# of using 'cd' shell commands.
270+
pane_has_same_path = lambda p: (
271+
w.panes[0].get('pane_current_path') ==
272+
p.get('pane_current_path')
273+
)
274+
275+
if (all(pane_has_same_path(p) for p in w.panes)):
274276
wconf['start_directory'] = w.panes[0].get('pane_current_path')
275277

276278
for p in w.panes:
@@ -284,14 +286,17 @@ def freeze(session):
284286

285287
current_cmd = p.get('pane_current_command')
286288

287-
if (
288-
current_cmd.startswith('-') or
289-
any(
290-
current_cmd.endswith(cmd)
291-
for cmd in ['python', 'ruby', 'node']
289+
def filter_interpretters_and_shells():
290+
return (
291+
current_cmd.startswith('-') or
292+
any(
293+
current_cmd.endswith(cmd)
294+
for cmd in ['python', 'ruby', 'node']
295+
)
292296
)
293-
):
294-
current_cmd = None
297+
298+
if (filter_interpretters_and_shells()):
299+
current_cmd = None
295300

296301
if current_cmd:
297302
pconf['shell_command'].append(current_cmd)

0 commit comments

Comments
 (0)