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 the command in --bind to open the original stdin #3241

Closed
10 tasks done
ericbn opened this issue Apr 7, 2023 · 1 comment
Closed
10 tasks done
Labels

Comments

@ericbn
Copy link

ericbn commented Apr 7, 2023

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

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

Hi 👋

Following up on #1723 for using fzf as a visualization tool rather than a filter, I'm trying to use fzf to turn jq into an interactive tool.

I'd like to be able to make the command in --bind receive the original stdin that fzf received. So instead of:

FZF_DEFAULT_COMMAND='jq . myfile.json' \
    fzf --disabled --layout=reverse --no-info --bind=enter:print-query \
    --bind='change:reload:jq {q} myfile.json'

I would instead be able to do something like:

cat myfile.json  | \
    fzf --disabled --layout=reverse --no-info --bind=enter:print-query \
    --bind='change:reload-sync:jq {q} <&0'

The latter would allow piping the output of other commands directly to fzf without needing to write the output to a file first.

Not sure if this is stretching the purpose of fzf too far...

EDIT: I'm aware of the tools that make jq interactive, or other tools like fx, jless, jellex, etc. that are also interactive JSON viewers, but using fzf has the benefit of both:

  1. being generic and being able to turn virtually any other tool interactive, and
  2. being powerful and allowing a lot of customization, for example we could switch between the interactive tool filter and fzf's filter.
@junegunn
Copy link
Owner

The standard input is a stream; we can't restart a stream. What fzf can do, is hold the raw input in memory and feed it to its child processes. But of course, that is not equivalent to rerunning the original command, so it may confuse the users.

(date; echo $RANDOM) | fzf

And I don't think fzf having to hold the original raw input in memory just in case the child process may use it can be justified.

Since the suggested feature doesn't solve a problem that can't be circumvented, I'm going to pass on this one, but thanks for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants