Skip to content

Commit 8fe461c

Browse files
committed
WIP: Command options
1 parent c47f361 commit 8fe461c

File tree

6 files changed

+55
-42
lines changed

6 files changed

+55
-42
lines changed

tests/fixtures/config/expand1.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,42 @@
3636
{
3737
"window_name": "editor",
3838
"panes": [
39-
{"shell_command": ["vim", "top"]},
40-
{"shell_command": ["vim"]},
41-
{"shell_command": ['cowsay "hey"']},
39+
{"shell_command": [{"cmd": "vim"}, {"cmd": "top"}]},
40+
{"shell_command": [{"cmd": "vim"}]},
41+
{"shell_command": [{"cmd": 'cowsay "hey"'}]},
4242
],
4343
"layout": "main-verticle",
4444
},
4545
{
4646
"window_name": "logging",
47-
"panes": [{"shell_command": ["tail -F /var/log/syslog"]}],
47+
"panes": [{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]}],
4848
},
4949
{
5050
"start_directory": "/var/log",
5151
"options": {"automatic-rename": True},
52-
"panes": [{"shell_command": ["htop"]}, {"shell_command": ["vim"]}],
52+
"panes": [
53+
{"shell_command": [{"cmd": "htop"}]},
54+
{"shell_command": [{"cmd": "vim"}]},
55+
],
5356
},
5457
{
5558
"start_directory": os.path.normpath(
5659
os.path.join(os.path.expanduser("~"), "./")
5760
),
58-
"panes": [{"shell_command": ["pwd"]}],
61+
"panes": [{"shell_command": [{"cmd": "pwd"}]}],
5962
},
6063
{
6164
"start_directory": os.path.normpath(
6265
os.path.join(os.path.expanduser("~"), "./asdf")
6366
),
64-
"panes": [{"shell_command": ["pwd"]}],
67+
"panes": [{"shell_command": [{"cmd": "pwd"}]}],
6568
},
6669
{
6770
"start_directory": os.path.normpath(
6871
os.path.join(os.path.expanduser("~"), "../")
6972
),
70-
"panes": [{"shell_command": ["pwd"]}],
73+
"panes": [{"shell_command": [{"cmd": "pwd"}]}],
7174
},
72-
{"panes": [{"shell_command": ["top"]}]},
75+
{"panes": [{"shell_command": [{"cmd": "top"}]}]},
7376
],
7477
}

tests/fixtures/config/expand2-expanded.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ windows:
66
focus: true
77
panes:
88
- shell_command:
9-
- cd ~
9+
- cmd: cd ~
1010
- shell_command:
11-
- cd /usr
11+
- cmd: cd /usr
1212
focus: true
1313
- shell_command:
14-
- cd ~
15-
- echo "moo"
16-
- top
14+
- cmd: cd ~
15+
- cmd: echo "moo"
16+
- cmd: top
1717
- window_name: window 2
1818
panes:
1919
- shell_command:
20-
- top
20+
- cmd: top
2121
focus: true
2222
- shell_command:
23-
- echo "hey"
23+
- cmd: echo "hey"
2424
- shell_command:
25-
- echo "moo"
25+
- cmd: echo "moo"
2626
- window_name: window 3
2727
panes:
2828
- shell_command:
29-
- cd /
29+
- cmd: cd /
3030
focus: true
3131
- shell_command: []
3232
- shell_command: []
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
shell_command_before:
2-
- 'echo "hi"'
2+
- cmd: 'echo "hi"'
33
session_name: 'test'
44
windows:
55
- window_name: editor
66
panes:
77
- shell_command:
8-
- 'echo "hi"'
9-
- vim
10-
- :Ex
8+
- cmd: 'echo "hi"'
9+
- cmd: vim
10+
- cmd: :Ex
1111
- shell_command:
12-
- 'echo "hi"'
12+
- cmd: 'echo "hi"'
1313
- shell_command:
14-
- 'echo "hi"'
15-
- cd /usr
14+
- cmd: 'echo "hi"'
15+
- cmd: cd /usr
1616
- window_name: logging
1717
panes:
1818
- shell_command:
19-
- 'echo "hi"'
19+
- cmd: 'echo "hi"'
2020
- shell_command:
21-
- 'echo "hi"'
22-
- top
23-
- emacs
21+
- cmd: 'echo "hi"'
22+
- cmd: top
23+
- cmd: emacs

tests/fixtures/config/trickle.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
{
66
"window_name": "editor",
77
"start_directory": "log",
8-
"panes": [{"shell_command": ["vim"]}, {"shell_command": ['cowsay "hey"']}],
8+
"panes": [
9+
{"shell_command": [{"cmd": "vim"}]},
10+
{"shell_command": [{"cmd": 'cowsay "hey"'}]},
11+
],
912
"layout": "main-verticle",
1013
},
1114
{
1215
"window_name": "logging",
1316
"start_directory": "~",
1417
"panes": [
15-
{"shell_command": ["tail -F /var/log/syslog"]},
18+
{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]},
1619
{"shell_command": []},
1720
],
1821
},
@@ -26,14 +29,17 @@
2629
{
2730
"window_name": "editor",
2831
"start_directory": "/var/log",
29-
"panes": [{"shell_command": ["vim"]}, {"shell_command": ['cowsay "hey"']}],
32+
"panes": [
33+
{"shell_command": [{"cmd": "vim"}]},
34+
{"shell_command": [{"cmd": 'cowsay "hey"'}]},
35+
],
3036
"layout": "main-verticle",
3137
},
3238
{
3339
"start_directory": "~",
3440
"window_name": "logging",
3541
"panes": [
36-
{"shell_command": ["tail -F /var/log/syslog"]},
42+
{"shell_command": [{"cmd": "tail -F /var/log/syslog"}]},
3743
{"shell_command": []},
3844
],
3945
},

tmuxp/config.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,23 @@ def expand(sconf, cwd=None, parent=None):
290290

291291
assert isinstance(p, dict)
292292
if "shell_command" in p:
293-
cmd = p["shell_command"]
293+
cmds = p["shell_command"]
294294

295295
if isinstance(p["shell_command"], str):
296-
cmd = [cmd]
296+
cmds = [cmds]
297297

298-
if not cmd or any(a == cmd for a in [None, "blank", "pane"]):
299-
cmd = []
298+
if not cmds or any(a == cmds for a in [None, "blank", "pane"]):
299+
cmds = []
300300

301-
if isinstance(cmd, list) and len(cmd) == int(1):
302-
if any(a in cmd for a in [None, "blank", "pane"]):
303-
cmd = []
301+
if isinstance(cmds, list) and len(cmds) == int(1):
302+
if any(a in cmds for a in [None, "blank", "pane"]):
303+
cmds = []
304304

305-
p["shell_command"] = cmd
305+
for cmd_idx, cmd in enumerate(cmds):
306+
if isinstance(cmd, str):
307+
cmds[cmd_idx] = {"cmd": cmd}
308+
309+
p["shell_command"] = cmds
306310
else:
307311
p["shell_command"] = []
308312

tmuxp/workspacebuilder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def get_pane_shell():
365365
enter = pconf.get("enter", True)
366366

367367
for cmd in pconf["shell_command"]:
368-
p.send_keys(cmd, suppress_history=suppress, enter=enter)
368+
p.send_keys(cmd["cmd"], suppress_history=suppress, enter=enter)
369369

370370
if "focus" in pconf and pconf["focus"]:
371371
w.select_pane(p["pane_id"])

0 commit comments

Comments
 (0)