Skip to content

Commit 1c4dd17

Browse files
committed
Initial commit of bash history suppression w/ example.
1 parent f0e5600 commit 1c4dd17

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed

examples/suppress-history.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"windows": [
3+
{
4+
"panes": [
5+
"echo 'in the history!'"
6+
],
7+
"focus": true,
8+
"suppress_history": false,
9+
"window_name": "appended"
10+
},
11+
{
12+
"panes": [
13+
"echo 'not in the history!'"
14+
],
15+
"suppress_history": true,
16+
"window_name": "suppressed"
17+
},
18+
{
19+
"panes": [
20+
"echo 'default not in the history!'"
21+
],
22+
"window_name": "default"
23+
},
24+
{
25+
"panes": [
26+
{
27+
"shell_command": "echo 'in the history!'",
28+
"suppress_history": false
29+
},
30+
{
31+
"shell_command": "echo 'not in the history!'",
32+
"suppress_history": true
33+
},
34+
{
35+
"shell_command": "echo 'default not in the history!'"
36+
}
37+
],
38+
"window_name": "mixed"
39+
}
40+
],
41+
"session_name": "suppress"
42+
}

examples/suppress-history.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
session_name: suppress
2+
windows:
3+
- window_name: appended
4+
focus: true
5+
suppress_history: false
6+
panes:
7+
- echo "in the history!"
8+
9+
- window_name: suppressed
10+
suppress_history: true
11+
panes:
12+
- echo "not in the history!"
13+
14+
- window_name: default
15+
panes:
16+
- echo "default not in the history!"
17+
18+
- window_name: mixed
19+
panes:
20+
- shell_command:
21+
- echo "in the history!"
22+
suppress_history: false
23+
- shell_command:
24+
- echo "not in the history!"
25+
suppress_history: true
26+
- shell_command:
27+
- echo "default not in the history!"

tmuxp/pane.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def cmd(self, cmd, *args, **kwargs):
7575

7676
return self.server.cmd(cmd, *args, **kwargs)
7777

78-
def send_keys(self, cmd, enter=True):
78+
def send_keys(self, cmd, enter=True, suppress_history=True):
7979
"""``$ tmux send-keys`` to the pane.
8080
8181
A leading space character is added to cmd to avoid polluting the
@@ -87,7 +87,8 @@ def send_keys(self, cmd, enter=True):
8787
:type enter: bool
8888
8989
"""
90-
self.cmd('send-keys', ' ' + cmd)
90+
prefix = ' ' if suppress_history else ''
91+
self.cmd('send-keys', prefix + cmd)
9192

9293
if enter:
9394
self.enter()

tmuxp/workspacebuilder.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,15 @@ def get_pane_start_directory():
261261
if 'layout' in wconf:
262262
w.select_layout(wconf['layout'])
263263

264+
if 'suppress_history' in pconf:
265+
suppress = pconf['suppress_history']
266+
elif 'suppress_history' in wconf:
267+
suppress = wconf['suppress_history']
268+
else:
269+
suppress = True
270+
264271
for cmd in pconf['shell_command']:
265-
p.send_keys(cmd)
272+
p.send_keys(cmd, suppress_history=suppress)
266273

267274
if 'focus' in pconf and pconf['focus']:
268275
w.select_pane(p['pane_id'])

0 commit comments

Comments
 (0)