Docfd

TUI multiline fuzzy document finder


Navigating repo:


Navigating "OCaml Programming: Correct + Efficient + Beautiful" book PDF and opening it to the closest location to the selected search result via PDF viewer integration:

Installation

Statically linked binaries are available via GitHub releases

Features

Integration details

Text editor integration

Docfd uses the text editor specified by $VISUAL (this is checked first) or $EDITOR.

Docfd opens the file at first line of search result for the following editors:

PDF viewer integration

Docfd guesses the default PDF viewer based on the output of xdg-mime query default application/pdf, and invokes the viewer either directly or via flatpak depending on where the desktop file can be first found in the list of directories specified by $XDG_DATA_DIRS.

Docfd opens the file at first page of the search result and starts a text search of the most unique word of the matched phrase within the same page for the following viewers:

Docfd opens the file at first page of the search result for the following viewers:

Usage

Read from piped stdin
command | docfd

Docfd uses Single file view when source of document is piped stdin.

Files specified as arguments to docfd are ignored in this case.

Read from files
docfd [PATH...]

The list of paths can contain directories. Each directory in the list is scanned recursively for files with one of the following extensions by default:

You can change the file extensions to use via --exts, or add onto the list of extensions via --add-exts.

If the list of paths is empty, then Docfd defaults to scanning the current directory ..

If any of the file ends with .pdf, then pdftotext is required to continue.

If exactly one file is specified in the list of paths, then Docfd uses Single file view. Otherwise, Docfd uses Multi-file view.

If any of the path is ?, then file selection of the discovered files via fzf is invoked.

Multi-file view

The default TUI is divided into four sections:

Controls

Docfd operates in modes, the initial mode is Navigation mode.

Navigation mode

Search mode

Require content mode

Search phrase and search procedure

Document content and user input in the search field are tokenized/segmented in the same way, based on:

A search phrase is a list of said tokens.

Search procedure is a DFS through the document index, where the search range for a word is fixed to a configured range surrounding the previous word (when applicable).

A token in the index matches a token in the search phrase if they are:

Search results are then ranked using heuristics.

File content requirements

The required content field accepts a content requirement expression.

A content requirement expression is one of:

Note that the edit distance is not considered here. Only case-insensitive exact matches or substring matches against the search phrases are considered.

In other words, given the same phrase, it is treated less fuzzily as a content requirement expression compared to being used as a search phrase in the search field.

Single file view

If the specified path to Docfd is not a directory, then single file view is used.

In this view, the TUI is divided into only two sections:

Controls

The controls are simplified in single file view, namely Shift is optional for scrolling through search result list.

Navigation mode

Search mode

Limitations

Acknowledgement