Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aider/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,10 @@ def get_parser(default_config_files, git_root):
"--editor",
help="Specify which editor to use for the /editor command",
)
group.add_argument(
"--fzf-history-search",
help="Use fuzzy find (fzf) for backwards history search",
)

supported_shells_list = sorted(list(shtab.SUPPORTED_SHELLS))
group.add_argument(
Expand Down
40 changes: 40 additions & 0 deletions aider/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def __init__(
root=".",
notifications=False,
notifications_command=None,
fzf_history_search=False,
):
self.placeholder = None
self.interrupted = False
Expand Down Expand Up @@ -371,6 +372,8 @@ def __init__(
# Validate color settings after console is initialized
self._validate_color_settings()

self.fzf_history_search = fzf_history_search

def _validate_color_settings(self):
"""Validate configured color strings and reset invalid ones."""
color_attributes = [
Expand Down Expand Up @@ -594,6 +597,43 @@ def _(event):
"Navigate forward through history"
event.current_buffer.history_forward()

if self.fzf_history_search:
@kb.add("c-r")
def _(event):
if not self.input_history_file:
self.tool_error("Reverse search attempt without history file")

event.app.reset()

return

history_lines = "\n".join(
FileHistory(self.input_history_file).load_history_strings()
)

fzf_result = (
subprocess.run(
["fzf", "--reverse", "--height", "20"],
check=False,
capture_output=True,
text=True,
input=history_lines,
)
)
if fzf_result.returncode != 0:
self.tool_error(f"fzf returned error: {fzf_result.stderr}")

event.app.reset()

return

fzf_output = fzf_result.stdout.rstrip("\n")

event.app.reset()
buffer = event.current_buffer
buffer.text = fzf_output
buffer.cursor_position = len(buffer.text)

@kb.add("c-x", "c-e")
def _(event):
"Edit current input in external editor (like Bash)"
Expand Down
1 change: 1 addition & 0 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ def get_io(pretty):
multiline_mode=args.multiline,
notifications=args.notifications,
notifications_command=args.notifications_command,
fzf_history_search=args.fzf_history_search,
)

io = get_io(args.pretty)
Expand Down