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
npm install --global fz-browse
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"
--run
: fz-browse execute therun
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
: fz-browse execute thepreview
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>
Please add your Recipes to Wiki!: https://github.com/azu/fz-browse/wiki/Recipes
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}"
Show ripgrep-all search results
- Requirements:
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
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 using exiftool.
- Requirements:
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
- epub
- Image: png,jpe,jpeg,webp,gif
git clone https://github.com/azu/fz-browse
cd fz-browse
yarn install
# using vite server
NODE_ENV=develop PORT=3000 node ./cli.mjs ...
MIT ©️ azu