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

[Feature request] allow for --query flag #1645

Closed
1 of 15 tasks
avshyz opened this issue Jul 23, 2019 · 1 comment
Closed
1 of 15 tasks

[Feature request] allow for --query flag #1645

avshyz opened this issue Jul 23, 2019 · 1 comment

Comments

@avshyz
Copy link

avshyz commented Jul 23, 2019

  • Category
    • 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

@adaszko
Copy link

adaszko commented Feb 14, 2020

As of 0.19.0, your use case is possible via --bind=change:reload:.... See also #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.

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

3 participants