Skip to content

[Discussion] Restarting source command #974

@junegunn

Description

@junegunn

#751 and #965 suggested a new mode of execution where fzf restarts the source command whenever the query string is changed. They specifically wanted this for using fzf with a primary search command such as grep, ag, or rg. Although I can see the appeal, there are obvious impedance mismatches.

  • fzf no longer works as the primary filter. It simply becomes a selector interface whose only role is to constantly restart child processes with the input.
  • fzf has its own search syntax, which is not compatible with the arguments for ag or rg.

And It's not just a simple option but a new, extra mode of execution that is not very "unix-y", and I'm concerned that it will hurt the conceptual simplicity of fzf.

A better idea I believe is to keep fzf simple and implement scripts using the existing options, and I think it's already possible to some level.

  1. Refresh the source command when a special key is pressed. This can be easily implemented using --expect option.
  2. Restart fzf and its source on every query change. This can be done using --bind change:accept, and some hacks. Little known and somewhat experimental --no-clear option can be used to reduce flickering of the screen, but unfortunately it doesn't work nicely with --height.

ag-change

(code: https://gist.github.com/junegunn/4963bab6ace453f7f529d2d0e01b1d85)

I'd like to focus on non-disruptive, incremental changes we can make to help the development of such scripts. Polishing --no-clear comes to my mind first.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions