Skip to content

Commit 4f9570d

Browse files
committed
Automatically run selected command on non-darwin platforms
1 parent 4d04747 commit 4f9570d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lldb/examples/python/fzf_history.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import sys
44
import subprocess
5+
import tempfile
56

67
import lldb
78

@@ -17,9 +18,17 @@ def fzf_history(debugger, cmdstr, ctx, result, _):
1718

1819
if sys.platform != "darwin":
1920
# The ability to integrate fzf's result into lldb uses copy and paste.
20-
# In absense of copy and paste, do the basics and forgo features.
21-
fzf_command = ("fzf", "--no-sort", f"--query={cmdstr}")
21+
# In absense of copy and paste, run the selected command directly.
22+
temp_file = tempfile.NamedTemporaryFile("r")
23+
fzf_command = (
24+
"fzf",
25+
"--no-sort",
26+
f"--query={cmdstr}",
27+
f"--bind=enter:execute-silent(echo -n {{}} > {temp_file.name})+accept",
28+
)
2229
subprocess.run(fzf_command, input=history, text=True)
30+
command = temp_file.read()
31+
debugger.HandleCommand(command)
2332
return
2433

2534
# Capture the current pasteboard contents to restore after overwriting.

0 commit comments

Comments
 (0)