Skip to content

azu/fz-browse

Repository files navigation

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

About

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

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published