Fzf: [Feature request] allow for --query flag

Created on 23 Jul 2019  路  1Comment  路  Source: junegunn/fzf

  • Category

    • [x] fzf binary

    • [ ] fzf-tmux script

    • [ ] Key bindings

    • [ ] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [ ] Linux

    • [ ] Mac OS X

    • [ ] Windows

    • [ ] Windows Subsystem for Linux

    • [ ] Etc.

  • Shell

    • [ ] bash

    • [ ] zsh

    • [ ] fish

Right now you have to pipe to fzf, and as you type fzf will filter the lines based on the text therein.

After reading this I've thought that it'd be really cool to add a flag to specify a query, which will allow fzf to be used without a pipe.
It might seem initially as an equal, albeit weirder, way to rephrase the usage of fzf (since command | fzf is equal to `fzf --query="command"). But this will allow for the query to change as you type to fzf!

A specifically interesting use-case:

fzf --query="git log -S{}" --preview="git show ..."
As you type, you will see the result of a git pickaxe search (looking for a commit containing a certain word [in the diff]), while the preview shows the hunk containing the change.

I believe adding that option would allow even for the development of tools with awesome interactivity.

What do you think?

edit: rephrasing

Most helpful comment

As of 0.19.0, your use case is possible via --bind=change:reload:.... See also https://github.com/junegunn/fzf/issues/1750. So

git log --color=always --pretty=oneline --no-abbrev-commit --decorate \
        | fzf --phony --bind="change:reload:git log -G{q} --color=always --pretty=oneline --no-abbrev-commit --decorate" \
              --preview="git show --color=always {1}" \
              --preview-window right:80% \
              --with-nth=2.. --layout=reverse --no-sort --ansi \
        | awk '{print $1}'

Replace -G with -S if you prefer the pickaxe behavior.

>All comments

As of 0.19.0, your use case is possible via --bind=change:reload:.... See also https://github.com/junegunn/fzf/issues/1750. So

git log --color=always --pretty=oneline --no-abbrev-commit --decorate \
        | fzf --phony --bind="change:reload:git log -G{q} --color=always --pretty=oneline --no-abbrev-commit --decorate" \
              --preview="git show --color=always {1}" \
              --preview-window right:80% \
              --with-nth=2.. --layout=reverse --no-sort --ansi \
        | awk '{print $1}'

Replace -G with -S if you prefer the pickaxe behavior.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asilvadesigns picture asilvadesigns  路  3Comments

natemara picture natemara  路  3Comments

lbeier picture lbeier  路  3Comments

firedev picture firedev  路  3Comments

olethanh picture olethanh  路  3Comments