Coder Social home page Coder Social logo

azu / fz-browse Goto Github PK

View Code? Open in Web Editor NEW
42.0 2.0 0.0 38.13 MB

fzf-like fuzzy finder tool but view search results on browser.

License: MIT License

TypeScript 1.04% JavaScript 93.97% HTML 1.32% CSS 3.67% Shell 0.01%
command-line finder fzf browser

fz-browse's Introduction

fz-browse

fz-browse is a general-purpose command-line fuzzy finder.

fz-browse is fzf-like tool but view search results on browser.

pdf-epub-search.mp4

Installation

npm install --global fz-browse

Usage

Usage
  $ fz-browse [option]

Options
  --run                        [String] Run command
  --preview                    [String] Preview command
  --cwd                        [String:Path] Current working directory
  --query                      [String] Default search query
  --open                       [Boolean] If it is set, open browser automatically
  --browser                    [String] for opening browser name: "google chrome", "firefox", "microsoft edge"
  --displayItemLimit           [Number] Limit count for display search results

Examples
  # Search text contents
  fz-browse --run $'rg --ignore-case {input} --json | jq \'if .type == "begin" or .type == "match" then . else empty end | [.data.path.text, .data.lines.text] | @tsv\' -r' --preview "rg --context 5 {input} {target}"
  # Search PDF/epub books
  fz-browse --run $'rga --ignore-case {input} --json | jq \'if .type == "begin" or .type == "match" then . else empty end | [.data.path.text, .data.lines.text] | @tsv\' -r' --preview "rga --context 5 {input} {target}" --cwd "/Path/To/Your/BookDir"

Command Output Format

Run command output format

  • --run: fz-browse execute the run command when input search keywords

--run command should output following file path by line.

/path/to/file
/path/to/file
/path/to/file

Also, support following TSV list by line. If you want to display content of the file in search result, --run command should output <filepath>\t<content> pattern.

/path/to/fileA
/path/to/fileA\tContent of the file A1
/path/to/fileA\tContent of the file A2
/path/to/fileA\tContent of the file A3
/path/to/fileB
/path/to/fileB\tContent of the file B1

It will be converted to following structure on view.

<h2><a href="/preview/?target=/path/to/fileA">/path/to/fileA</a></h2>

<p>Content of the file A1</p>
<p>Content of the file A2</p>
<p>Content of the file A3</p>

<h2><a href="/preview/?target=/path/to/fileB">/path/to/fileB</a></h2>

<p>Content of the file B1</p>

๐Ÿ“ Empty TSV line will be ignored.

/path/to/fileA
/path/to/fileA\tContent of the file A1
/path/to/fileA\tContent of the file A2
/path/to/fileA\tContent of the file A3
\t # This line will be ignored

Preview command output format

  • --preview: fz-browse execute the preview command when click the search result

--preview command should output following content by line.

content A
content B
content C

It will be converted to following structure on view.

<p>content A</p>
<p>content B</p>
<p>content C</p>

Architecture

architecture.

Recipes

Please add your Recipes to Wiki!: https://github.com/azu/fz-browse/wiki/Recipes

Search text contents

Show ripgrep search results

fz-browse --run $'rg --ignore-case {input} --json | jq \'if .type == "begin" or .type == "match" then . else empty end | [.data.path.text, .data.lines.text] | @tsv\' -r' --preview "rg --context 5 {input} {target}"

Search PDF and epub books

Show ripgrep-all search results

fz-browse --run $'rga --ignore-case {input} --json | jq \'if .type == "begin" or .type == "match" then . else empty end | [.data.path.text, .data.lines.text] | @tsv\' -r' --preview "rga --context 5 {input} {target}" --cwd "/Path/To/Your/BookDir"
Description

It means that convert only "begin" and "match" JSON line to TSV.

rga test --json | jq 'if .type == "begin" or .type == "match" then 
  .     # Pass it-self to next pipe
else 
  empty # remove this live
end | [.data.path.text, .data.lines.text] | @tsv'

Open browser automatically

--open and --browser <browsername> allow you to open a browser.

fz-browse --run $'rg --ignore-case {input} --json | jq \'if .type == "begin" or .type == "match" then . else empty end | [.data.path.text, .data.lines.text] | @tsv\' -r' --preview "rg --context 5 {input} {target}" --open --browser "google chrome"

Search Images by Exif data

Search Images using exiftool.

fz-browse --run $'find -E . -iregex ".*\.(jpg|gif|png|jpeg)$" -print0 | xargs -0 exiftool -q -m -p \'$Directory/$Filename  $DateTimeOriginal  $Comment\' | grep {input} | awk \'{print $1}\'' --preview "echo {target}"
image-search.mp4

Built-in Preview

  • PDF
  • epub
  • Image: png,jpe,jpeg,webp,gif

Develop

git clone https://github.com/azu/fz-browse
cd fz-browse
yarn install
# using vite server
NODE_ENV=develop PORT=3000 node ./cli.mjs ...

License

MIT ยฉ๏ธ azu

fz-browse's People

Contributors

azu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fz-browse's Issues

Plugin system

User can custom Preview comonent and routing patterns.

For example, user can create movie player for preview.

Plugin system

User can custom Preview comonent and routing patterns.

For example, user can create movie player for preview.

Unexpected reserved word

Hi, I installed with the npm command (got the warning below)
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@remix-run/[email protected]',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN deprecated [email protected]: Please use another csrf package

I ran this command, from your example with changed directory):

fz-browse --run $'find -E ~/downloads -iregex ".*.(jpg|gif|png|jpeg)$" -print0 | xargs -0 exiftool -q -m -p '$Directory/$Filename $DateTimeOriginal $Comment' | grep {input} | awk '{print $1}'' --preview "echo {target}"
file:///usr/local/lib/node_modules/fz-browse/cli.mjs:66
const server = await createServer({
^^^^^

SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
at async link (internal/modules/esm/module_job.js:42:21)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.