Skip to content

Commit

Permalink
fix fzf ctrl-g #121
Browse files Browse the repository at this point in the history
  • Loading branch information
laktak committed May 23, 2024
1 parent 4a5265b commit 13f2645
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions extrakto_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
import re
import subprocess
import sys
import traceback

from collections import OrderedDict
from extrakto import Extrakto, get_lines

if len(sys.argv) < 3:
print("Usage: extrakto-plugin.py trigger_pane launch_mode")
sys.exit(1)


PLATFORM = platform.system()
PRJ_URL = "https://github.com/laktak/extrakto"
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -301,26 +297,37 @@ def capture(self):

# for troubleshooting add `tee /tmp/stageN | ` between the commands
try:
fzf_cmd = [
self.fzf_tool,
"--multi",
"--print-query",
f"--query={query}",
f"--header={header}",
f"--expect=ctrl-c,ctrl-g,esc",
f"--expect={self.insert_key},{self.copy_key},{self.filter_key},{self.edit_key},{self.open_key},{self.grab_key},{self.help_key}",
"--tiebreak=index",
f"--layout={self.fzf_layout}",
"--no-info",
]
query, key, *selection = fzf_sel(
[
self.fzf_tool,
"--multi",
"--print-query",
f"--query={query}",
f"--header={header}",
f"--expect={self.insert_key},{self.copy_key},{self.filter_key},{self.edit_key},{self.open_key},{self.grab_key},{self.help_key},ctrl-c,esc",
"--tiebreak=index",
f"--layout={self.fzf_layout}",
"--no-info",
],
fzf_cmd,
get_cap(mode, self.capture_panes()),
)
except Exception as e:
print(e)
print("error: unable to extract - check/report errors above")
print("You can also set the fzf path in options (see readme).")
input()
sys.exit(1)
msg = (
str(fzf_cmd)
+ "\n"
+ traceback.format_exc()
+ "\n"
+ "error: unable to extract - check/report errors above"
+ "\n"
+ "If fzf is not found you need to set the fzf path in options (see readme)."
)
print(msg)
confirm = input("Copy this message to the clipboard? [Y/n]")
if confirm != "n":
self.copy(msg)
sys.exit(0)

text = ""
if mode == "all":
Expand Down Expand Up @@ -407,4 +414,8 @@ def capture(self):


if __name__ == "__main__":
ExtraktoPlugin(sys.argv[1], sys.argv[2]).capture()
if len(sys.argv) < 3:
print("Usage: extrakto-plugin.py trigger_pane launch_mode")
sys.exit(1)
else:
ExtraktoPlugin(sys.argv[1], sys.argv[2]).capture()

0 comments on commit 13f2645

Please sign in to comment.