Skip to content

Commit e143336

Browse files
authored
feat: Command level enter: false (#755)
Related to #53 #293 #735
2 parents 091cb56 + 177dd18 commit e143336

8 files changed

+134
-11
lines changed

CHANGES

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
session_name: Should not execute
1313
windows:
1414
- panes:
15-
- shell_command: echo "___$((1 + 3))___"
15+
- shell_command:
16+
- cmd: echo "___$((1 + 3))___"
17+
enter: false
18+
19+
# pane-wide skip
20+
- shell_command:
21+
- echo "___$((1 + 3))___"
1622
enter: false
1723
```
1824
@@ -71,7 +77,7 @@
7177

7278
- #752: Command structure (internal API)
7379

74-
To pave the way for per-command options such as `enter: false` (#52), commands are now a different format:
80+
To pave the way for per-command options such as `enter: false` (#53), commands are now a different format:
7581

7682
Before, [`str`](str):
7783

docs/examples.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ This will add the `shell_command` to the bash history in the pane.
331331
## Skip command execution
332332

333333
```{versionadded} 1.10.0b1
334-
`enter: false` option. This is only available at the pane (not command level)
335-
until [#751](https://github.com/tmux-python/tmuxp/issues/751) is published.
334+
`enter: false` option. Pane-level support.
335+
```{versionadded} 1.10.0b3
336+
Support command-level skipping.
336337
```
337338

338339
Omit sending {kbd}`enter` to key commands. Equivalent to
@@ -356,6 +357,25 @@ Omit sending {kbd}`enter` to key commands. Equivalent to
356357
357358
````
358359

360+
````{tab} YAML (pane-level)
361+
362+
```{literalinclude} ../examples/skip-send-pane-level.yaml
363+
:language: yaml
364+
365+
```
366+
367+
````
368+
369+
````{tab} JSON (pane-level)
370+
371+
```{literalinclude} ../examples/skip-send-pane-level.json
372+
:language: json
373+
374+
```
375+
376+
````
377+
378+
359379
## Window Index
360380

361381
You can specify a window's index using the `window_index` property. Windows

examples/skip-send-pane-level.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"session_name": "Skip all pane commands",
3+
"windows": [
4+
{
5+
"panes": [
6+
{
7+
"shell_command": "echo \"___$((1 + 3))___\"",
8+
"enter": false
9+
},
10+
{
11+
"shell_command": [
12+
"echo \"___$((1 + 3))___\"\\;",
13+
"echo \"___$((1 + 3))___\""
14+
],
15+
"enter": false
16+
}
17+
]
18+
}
19+
]
20+
}

examples/skip-send-pane-level.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
session_name: Skip all pane commands
2+
windows:
3+
- panes:
4+
- shell_command: echo "___$((1 + 3))___"
5+
enter: false
6+
- shell_command:
7+
- echo "___$((1 + 3))___"\;
8+
- echo "___$((1 + 3))___"
9+
enter: false

examples/skip-send.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
2-
"session_name": "Should not execute",
2+
"session_name": "Skip command execution (command-level)",
33
"windows": [
44
{
55
"panes": [
66
{
7-
"shell_command": "echo \"___$((1 + 3))___\"",
8-
"enter": false
7+
"shell_command": [
8+
"echo \"___$((11 + 1))___\"",
9+
{
10+
"cmd": "echo \"___$((1 + 3))___\"",
11+
"enter": false
12+
}
13+
]
914
}
1015
]
1116
}

examples/skip-send.yaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
session_name: Should not execute
1+
session_name: Skip command execution (command-level)
22
windows:
33
- panes:
4-
- shell_command: echo "___$((1 + 3))___"
5-
enter: false
4+
- shell_command:
5+
# You can see this
6+
- echo "___$((11 + 1))___"
7+
# This is skipped
8+
- cmd: echo "___$((1 + 3))___"
9+
enter: false

tests/test_workspacebuilder.py

+58
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,60 @@ def test_find_current_active_pane(server, monkeypatch):
919919
- panes:
920920
- shell_command:
921921
- echo "___$((1 + 3))___"
922+
"""
923+
),
924+
"___4___",
925+
True,
926+
],
927+
[
928+
textwrap.dedent(
929+
"""
930+
session_name: Should not execute
931+
windows:
932+
- panes:
933+
- shell_command:
934+
- cmd: echo "___$((1 + 3))___"
935+
enter: false
936+
"""
937+
),
938+
"___4___",
939+
False,
940+
],
941+
[
942+
textwrap.dedent(
943+
"""
944+
session_name: Should not execute
945+
windows:
946+
- panes:
947+
- shell_command:
948+
- cmd: echo "___$((1 + 3))___"
949+
enter: false
950+
"""
951+
),
952+
"___4___",
953+
False,
954+
],
955+
[
956+
textwrap.dedent(
957+
"""
958+
session_name: Should execute
959+
windows:
960+
- panes:
961+
- shell_command: echo "___$((1 + 3))___"
962+
"""
963+
),
964+
"___4___",
965+
True,
966+
],
967+
[
968+
textwrap.dedent(
969+
"""
970+
session_name: Should execute
971+
windows:
972+
- panes:
973+
- shell_command:
974+
- cmd: echo "other command"
975+
- cmd: echo "___$((1 + 3))___"
922976
"""
923977
),
924978
"___4___",
@@ -930,6 +984,10 @@ def test_find_current_active_pane(server, monkeypatch):
930984
"pane_enter_false_longform",
931985
"pane_enter_default_shortform",
932986
"pane_enter_default_longform",
987+
"pane_command_enter_false_shortform",
988+
"pane_command_enter_false_longform",
989+
"pane_command_enter_default_shortform",
990+
"pane_command_enter_default_longform",
933991
],
934992
)
935993
def test_load_workspace_enter(

tmuxp/workspacebuilder.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ def get_pane_shell():
363363
suppress = True
364364

365365
enter = pconf.get("enter", True)
366-
367366
for cmd in pconf["shell_command"]:
367+
enter = cmd.get("enter", enter)
368+
368369
p.send_keys(cmd["cmd"], suppress_history=suppress, enter=enter)
369370

370371
if "focus" in pconf and pconf["focus"]:

0 commit comments

Comments
 (0)