Skip to content

Commit 3a6830b

Browse files
committed
wip
1 parent c2ea384 commit 3a6830b

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

tests/fixtures/config/shell_command_before_session-expected.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
shell_command_before:
2-
- 'echo "hi"'
2+
- shell_command:
3+
- 'echo "hi"'
34
session_name: 'test'
45
windows:
56
- window_name: editor

tmuxp/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ def load_workspace(
659659
sconfig["session_name"] = new_session_name
660660
# propagate config inheritance (e.g. session -> window, window -> pane)
661661
sconfig = config.trickle(sconfig)
662+
print(sconfig)
662663

663664
t = Server( # create tmux server object
664665
socket_name=socket_name,

tmuxp/config.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ def inline(sconf):
152152

153153
if len(sconf.keys()) == int(1):
154154
sconf = sconf["shell_command"]
155-
# todo rewrite inlines
156-
# if (
157-
# "shell_command_before" in sconf
158-
# and isinstance(sconf["shell_command_before"], list)
159-
# and len(sconf["shell_command_before"]) == 1
160-
# ):
161-
# sconf["shell_command_before"] = sconf["shell_command_before"][0]
155+
156+
if (
157+
"shell_command_before" in sconf
158+
and isinstance(sconf["shell_command_before"], list)
159+
and len(sconf["shell_command_before"]) == 1
160+
):
161+
sconf["shell_command_before"] = sconf["shell_command_before"][0]
162162

163163
# recurse into window and pane config items
164164
if "windows" in sconf:
@@ -271,12 +271,19 @@ def expand(sconf, cwd=None, parent=None):
271271
sconf["shell_command_before"], list
272272
):
273273
for i, scmd in enumerate(sconf["shell_command_before"]):
274-
if isinstance(scmd, dict):
275-
scmd["shell_command"] = expandshell(scmd.get("shell_command"))
276274
if isinstance(scmd, str):
277-
scmd = {"shell_command": expandshell(scmd)}
275+
scmd = [expandshell(scmd)]
276+
if isinstance(scmd, list):
277+
for _i, subcmd in enumerate(scmd):
278+
if isinstance(subcmd, str):
279+
subcmd = {"shell_command": subcmd}
280+
281+
shell_command = subcmd.get("shell_command")
282+
if isinstance(shell_command, list):
283+
shell_command[:] = [expandshell(_s) for _s in shell_command]
284+
scmd[_i] = subcmd
285+
278286
sconf["shell_command_before"][i] = scmd
279-
print(sconf)
280287

281288
# recurse into window and pane config items
282289
if "windows" in sconf:
@@ -461,7 +468,7 @@ def import_tmuxinator(sconf):
461468
if "shell_command_before" not in tmuxp_config:
462469
tmuxp_config["shell_command_before"] = []
463470
tmuxp_config["shell_command_before"].append(
464-
{"shell_command": "rbenv shell %s" % sconf["rbenv"]}
471+
{"shell_command": ["rbenv shell %s" % sconf["rbenv"]]}
465472
)
466473

467474
for w in sconf["windows"]:

tmuxp/workspacebuilder.py

+1
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ def get_pane_shell():
365365

366366
enter = pconf.get("enter", True)
367367
sleep = pconf.get("sleep", None)
368+
print(pconf)
368369
for cmd in pconf["shell_command"]:
369370
if sleep is not None:
370371
time.sleep(sleep)

0 commit comments

Comments
 (0)