Fzf: Feature Request: Command to open currently filtered output as a file into another program

Created on 19 Nov 2019  路  8Comments  路  Source: junegunn/fzf

  • [x] I have read through the manual page (man fzf)
  • [x] I have the latest version of fzf
  • [x] I have searched through the existing issues

Info

  • OS

    • [x] Linux

    • [ ] Mac OS X

    • [ ] Windows

    • [ ] Etc.

  • Shell

    • [x] bash

    • [ ] zsh

    • [ ] fish

Problem / Steps to reproduce

Feature request.
Mapping a key which - on pressing it - passes all the lines in fzf's buffer as a file as an argument to some program.

Example:
--bind "enter:execute(less {f}) where {f} would be a something like bash's process substitution where you can write any command using this syntax vim <(less file) and <(less file) is a new file descriptor itself. {f} could also be implemented using a temporary file.

This way one could have a convenient way to open all the lines of the current fzf buffer in another program.

My specific use case, why I am asking for this: I use fzf as a tool to filter huge log output on-the-fly to only see the things I am interested within that log. But often enough I also want to search within that filtered output, so opening everything that's displayed by fzf right now in another program like less would be very convenient. So there should be a way to open the current filtered output and to open all the lines fzf received so far regardless of the current query.

Most helpful comment

Thanks. Also check out {+f} which was added in 0.19.0.

https://github.com/junegunn/fzf/blob/master/CHANGELOG.md#0190

All 8 comments

Or, even better, something like a second "mode" within fzf, to be able to search text within the filtered lines

Do you have the latest version of fzf?

0.19.0 yes

+1
I also want this feature.
My use case: I have some candidate keywords to search and explore, I want fzf to have the capability of outputing the filter results to a file (for later analysis) by pressing a key without closing the current fzf sessions. By this way, I could generate different filter outputs for diffferent search keywords in one single fzf session. And then, when I am out of idea, I would close the current fzf session and start to analyze these output files later.
Wish: I learn that fzf supports the variable {} to represent the currently selected line. I wish that fzf would have another variable (e.g. []) to represent for the whole current filter outputs.

# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy)
fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'

is there any reason your not using {+} to represent all toggled items?

--bind='ctrl-v:toggle-all+execute:less -f {+}'  
--bind='ctrl-n:toggle-all+execute:tee -a ~/tempresults <{+}' #will output contents of all selected files to tempresults
--bind='ctrl-p:toggle-all+execute:echo {+} >> ~/tempresults' #will output the names of selected files to tempresults

Theres also the 鈥攕ync flag for multi stage searches

Many thanks @rayiik for the pointers, very details! 馃憤
I was not aware of many support placeholders by the new version of fzf.
I have enough constructs for my custom workflow now.

Cool enjoy :)

Thanks. Also check out {+f} which was added in 0.19.0.

https://github.com/junegunn/fzf/blob/master/CHANGELOG.md#0190

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aleclarson picture aleclarson  路  3Comments

firedev picture firedev  路  3Comments

olethanh picture olethanh  路  3Comments

jan-warchol picture jan-warchol  路  3Comments

leonklingele picture leonklingele  路  3Comments