Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for re-executing a command on input #965

Closed
1 task done
cstrahan opened this issue Jul 6, 2017 · 2 comments
Closed
1 task done

support for re-executing a command on input #965

cstrahan opened this issue Jul 6, 2017 · 2 comments

Comments

@cstrahan
Copy link

cstrahan commented Jul 6, 2017

  • Category
    • fzf binary

I would like to use fzf to interactively run grep (or ag/ack/etc), where typing would cause grep to be re-executed as necessary. Ideally, there would be a configurable debounce setting, so quickly typing text doesn't trigger the command excessively. In case visuals help, this is basically the use case I have in mind (from syohex/emacs-helm-ag):

helm-do-ag

In this case, fzf would be less of a fuzzy finder, and more of a generic selection interface.

Is this a feature that would be accepted? If so, I might find time to work on it.

@cstrahan
Copy link
Author

cstrahan commented Jul 6, 2017

It appears I'm not alone: https://www.reddit.com/r/vim/comments/4kjeur/live_searching_in_vim/

The wiki suggests something like this: ag --nobreak --nonumbers --noheading . | fzf

But, to be clear, that essentially just cats each file recursively, with the one bonus being that .gitignored files are left out; from there, the file contents are fuzzy matched as per usual.

What I'm looking for is a way to treat the currently entered text as a proper regex to hand of to e.g. ag after each edit.

@junegunn
Copy link
Owner

junegunn commented Jul 7, 2017

You can see the previous discussion on the matter here: #751. There are questions and concerns that haven't been addressed, and I still don't think I want to add the exact feature to fzf, well at least for now. As you mentioned above, it's clear that this is not the type of problem fzf was initially designed to solve. It's introducing another mode of execution; fzf no longer acts as a filter, filtering is completely performed by some external program, and this mode will not work with STDIN. What I'm mainly concerned is that adding this new mode may hurt the simplicity of the project. Maybe there are programs that are better suited, particularly designed for this use case? Or you can just take a look at the project mentioned in the previous issue.

I'm actually quite content with the current workflow, using ag as the primary filter, and fzf as the secondary. Most of the time I know what I'm looking for, so I have no problem coming up with the base query for ag, and even if I don't, "catting" every file and feeding the lines into fzf works quite well for small to mid-sized projects that have less than a few million lines in total. And though it's not exactly what you want but fzf provides --expect and --print-query options that you can use to implement a way to restart the command pipeline with the current query if that's necessary.

Having said that, it's not that I'm totally against the idea, I just don't find myself needing it so it's not my priority. And I'd like to think about it really hard and go over pros and cons of all the options before rushing into an implementation. There might be better ways to integrate the feature without sacrificing the conceptual simplicity of fzf.

Will revisit this later, but I'm going to close it for now. Thanks for the suggestion.

@junegunn junegunn closed this as completed Jul 7, 2017
junegunn added a commit that referenced this issue Nov 10, 2019
  # Reload input list with different sources
  seq 10 | fzf --bind 'ctrl-a:reload(seq 100),ctrl-b:reload(seq 1000)'

  # Reload as you type
  seq 10 | fzf --bind 'change:reload:seq {q}' --phony

  # Integration with ripgrep
  RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
  INITIAL_QUERY=""
  FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
    fzf --bind "change:reload:$RG_PREFIX {q} || true" \
        --ansi --phony --query "$INITIAL_QUERY"

Close #751
Close #965
Close #974
Close #1736
Related #1723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants