feat: pass fzf opts

This commit is contained in:
Benexl
2025-07-13 12:29:57 +03:00
parent f02f92b80b
commit b847e02fe0

View File

@@ -1,4 +1,5 @@
import logging
import os
import shutil
import subprocess
@@ -15,11 +16,8 @@ class FzfSelector(BaseSelector):
if not self.executable:
raise FileNotFoundError("fzf executable not found in PATH.")
os.environ["FZF_DEFAULT_OPTS"] = self.config.opts
# You can prepare default opts here from the config
if config.opts:
self.default_opts = self.config.opts.splitlines()
else:
self.default_opts = []
def choose(self, prompt, choices, *, preview=None, header=None):
fzf_input = "\n".join(choices)
@@ -43,11 +41,9 @@ class FzfSelector(BaseSelector):
return result.stdout.strip()
def confirm(self, prompt, *, default=False):
# FZF is not great for confirmation, but we can make it work
choices = ["Yes", "No"]
default_choice = "Yes" if default else "No"
# A simple fzf call can simulate this
result = self.choose(choices, prompt, header=f"Default: {default_choice}")
result = self.choose(prompt, choices, header=f"Default: {default_choice}")
return result == "Yes"
def ask(self, prompt, *, default=None):