Skip to content

Commit 67e9a2f

Browse files
committed
Added session-level history suppression.
1 parent 1c4dd17 commit 67e9a2f

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

doc/examples.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,25 @@ JSON
241241
.. literalinclude:: ../examples/focus-window-and-panes.json
242242
:language: json
243243

244+
Terminal History
245+
----------------
246+
247+
tmuxp allows ``suppress_history: false`` to override the default command /
248+
suppression when building the workspace.
249+
This will add the ``shell_command`` to the bash history in the pane.
250+
251+
YAML
252+
~~~~
253+
254+
.. literalinclude:: ../examples/suppress-history.yaml
255+
:language: yaml
256+
257+
JSON
258+
~~~~
259+
260+
.. literalinclude:: ../examples/suppress-history.json
261+
:language: json
262+
244263
Window Index
245264
------------
246265

examples/suppress-history.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,43 @@
22
"windows": [
33
{
44
"panes": [
5-
"echo 'in the history!'"
5+
"echo 'window in the history!'"
66
],
77
"focus": true,
88
"suppress_history": false,
99
"window_name": "appended"
1010
},
1111
{
1212
"panes": [
13-
"echo 'not in the history!'"
13+
"echo 'window not in the history!'"
1414
],
1515
"suppress_history": true,
1616
"window_name": "suppressed"
1717
},
1818
{
1919
"panes": [
20-
"echo 'default not in the history!'"
20+
"echo 'session in the history!'"
2121
],
2222
"window_name": "default"
2323
},
2424
{
2525
"panes": [
2626
{
27-
"shell_command": "echo 'in the history!'",
27+
"shell_command": "echo 'command in the history!'",
2828
"suppress_history": false
2929
},
3030
{
31-
"shell_command": "echo 'not in the history!'",
31+
"shell_command": "echo 'command not in the history!'",
3232
"suppress_history": true
3333
},
3434
{
35-
"shell_command": "echo 'default not in the history!'"
35+
"shell_command": "echo 'window not in the history!'"
3636
}
3737
],
38+
"suppress_history": true,
3839
"window_name": "mixed"
3940
}
4041
],
42+
"suppress_history": false,
4143
"session_name": "suppress"
4244
}

examples/suppress-history.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
session_name: suppress
2+
suppress_history: false
23
windows:
34
- window_name: appended
45
focus: true
56
suppress_history: false
67
panes:
7-
- echo "in the history!"
8+
- echo "window in the history!"
89

910
- window_name: suppressed
1011
suppress_history: true
1112
panes:
12-
- echo "not in the history!"
13+
- echo "window not in the history!"
1314

1415
- window_name: default
1516
panes:
16-
- echo "default not in the history!"
17+
- echo "session in the history!"
1718

1819
- window_name: mixed
20+
suppress_history: false
1921
panes:
2022
- shell_command:
21-
- echo "in the history!"
23+
- echo "command in the history!"
2224
suppress_history: false
2325
- shell_command:
24-
- echo "not in the history!"
26+
- echo "command not in the history!"
2527
suppress_history: true
2628
- shell_command:
27-
- echo "default not in the history!"
29+
- echo "window in the history!"

tmuxp/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ def trickle(sconf):
309309
else:
310310
session_start_directory = None
311311

312+
if 'suppress_history' in sconf:
313+
suppress_history = sconf['suppress_history']
314+
else:
315+
suppress_history = None
316+
312317
for windowconfig in sconf['windows']:
313318

314319
# Prepend start_directory to relative window commands
@@ -325,6 +330,11 @@ def trickle(sconf):
325330
)
326331
windowconfig['start_directory'] = window_start_path
327332

333+
# We only need to trickle to the window, workspace builder checks wconf
334+
if suppress_history is not None:
335+
if not 'suppress_history' in windowconfig:
336+
windowconfig['suppress_history'] = suppress_history
337+
328338
for paneconfig in windowconfig['panes']:
329339
commands_before = []
330340

0 commit comments

Comments
 (0)