cboxdoerfer / fsearch

A fast file search utility for Unix-like systems based on GTK3
GNU General Public License v2.0
3.33k stars 209 forks source link

command line interface #463

Open danielkrajnik opened 1 year ago

danielkrajnik commented 1 year ago

Describe the solution you'd like CLI interface in fsearch, e.g. fsearch --search .pdf would output resulting file paths to stdout instead of opening fsearch gui. This would allow us to build pipelines around fsearch with other command line tools.

Describe alternatives you've considered GNU mlocate provides it already, but it's a bit of a pain to maintain two databases.

Additional context It's been mentioned in this issue, but API was proposed instead.

If we could add this kind of CLI an option to sort results by name or date would probably be useful, as well.

cboxdoerfer commented 1 year ago

Thx for the idea. This is already on my TODO list. I'll probably add additional command line flags to control the output and sort oder. So something like this: fsearch --output="${path}\t${size}" --sort="${name}" --search="*.pdf"

I'll see if I can squeeze this in to the 0.3 release.

danielkrajnik commented 1 year ago

Oh I haven't seen the TODO list, thanks. That's good to hear, hopefully it won't take too long to add it.

Yes, I think that there could be more useful options, but the less verbose the better I'd say, for example when using plocate locate portfolio .pdf home command is the same as locate "*portfolio*.pdf*home". Also ideally without the equal signs 😅

cboxdoerfer commented 1 year ago

Yes, I think that there could be more useful options, but the less verbose the better I'd say, for example when using plocate locate portfolio .pdf home command is the same as locate "portfolio.pdf*home".

I guess one way to reduce the verbosity is to have a dedicated binary (e.g. fsearch-cli or fsearchq) for the CLI interface, something like:

fsearch-cli [OPTIONAL_FLAGS] LIST_OF_SEARCH_TERMS

Because I don't want to get rid of the functionality to forward searches to the GUI with fsearch --search=SEARCH_TERM.

when using plocate locate portfolio .pdf home command is the same as locate "*portfolio*.pdf*home"

I don't think so, the former (which is also how FSearch works) will find home_portfolio.pdf and portfolio_home.pdf and portfolio.pdf.home (i.e. the order doesn't matter), while the later will only find portfolio.pdf.home because that's the only one which has portolio followed by .pdf followed by home.

So the equivalent to locate portfolio .pdf home with fsearch-cli would simply be fsearch-cli portfolio .pdf home

Also ideally without the equal signs

Yes, the equal signs can already be omitted. (fsearch --search test is the same as fsearch --search=test)

danielkrajnik commented 1 year ago

fsearch-cli or fsearchq

great idea

the equivalent to locate portfolio .pdf home with fsearch-cli would simply be fsearch-cli portfolio .pdf home

Yes, that would be perfect. Sorry, all I meant is that the syntax without the special characters (* " or =) would seem to be better (less typing).

jeffrey4l commented 2 months ago

hope this can be implemented, thanks a lot