Fd: Feature request: limit the number of find result

Created on 13 Sep 2019  Â·  12Comments  Â·  Source: sharkdp/fd

When used with emacs helm, fd process is created after every char inputting. I want to limit the number of the find result, because the extra results have no use and just cost power.

If there are too many results (more than 100 for me), I will find again until the results are less than 30. This is my common use(99%).

question

Most helpful comment

This has now been released in fd v8.0.

All 12 comments

Would

fd … | head -n 30

work for you?

If you want colorized output, you can use

fd --color=always … | head -n 30

see also my answer in #472.

Good idea. It works on macOS. But on windows, there is no 'head' command. I would have to install msys2 to use it.

I'd like to close this in favor of #472 (even if this is slightly more general).

It's not very likely that we will implement a separate command-line option for this, given that there are reasonable alternatives.

This has actually been implemented as --max-results=<count> in #555

Thanks.

@sharkdp great news, thanks for implementing this feature! :+1:

What do you think about making it a one-line option -n <count> with obvious references to head / tail commands? It's associated with lines and numbers quite commonly, including bat, hexyl, ripgrep, cat etc.

@sharkdp great news, thanks for implementing this feature! +1

thank you for the feedback.

What do you think about making it a one-line option -n <count> with obvious references to head / tail commands? It's associated with _lines and numbers_ quite commonly, including bat, hexyl, ripgrep, cat etc.

I'd rather not, at least not right away. Let's see how this feature develops for some time. What is your most common use case of --max-results? Limiting to just one result? In this case we could also think about adding -1 as an alias for --max-results=1.

What is your most common use case of --max-results? Limiting to just one result?

Indeed it's quite often just a single file. I use such fd command to pick a random file of specific extension from a root media directory (wallpapers or audio library) with subdirectories. In zsh corresponding glob is **.png(.Y1), where ** allows recursing, Y1 means yield 1, . means it must be a file.

In this case we could also think about adding -1 as an alias for --max-results=1.

That's a really good idea!

see #561

This has now been released in fd v8.0.

Thanks! It's already in Arch repos and of course works:

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dietr1ch picture Dietr1ch  Â·  3Comments

longcp picture longcp  Â·  3Comments

mathomp4 picture mathomp4  Â·  4Comments

runiq picture runiq  Â·  3Comments

blueray453 picture blueray453  Â·  3Comments