I recently found myself searching for an alternative to the great, Windows-based file search tool Everything on Linux.
Many Linux alternatives exist, fsearch, plocate, docfetcher, recoll to name a few, but all of them were either trying to do too much in a single application (fsearch, docfetcher, recoll), or did not have the advantage of interactive search (plocate).
I figured adding interactive search to plocate would be the most straight-forward way to achieve my goal, and went about creating an initial version, tlocate. To faciliate the interactive querying, we simply fork plocate every time the query changes, and collect the output through a pipe. To quickly and memory efficently index the entries, they are stored in a single chunk, and a second array keeps track of the offsets in that chunk which correspond to the entry delimeter (newline by default). The rest is just a matter of using ncurses to display and navigate the entries.
Eventually, I realized that this approach generalizes quite well to querying arbitrary other programs, not just plocate, and named the new, more UNIX-like version of the program tquery.
The program fits inside a single, small C file.
Granted, I am using
libdvec for the vector
implementation, but even without these dependencies the total
LOC would not exceed 1000 (~500 LOC atm).
You can find the source code at
To keep the program simple, I've limited the amount of commandline options,
and dont intend to add many more. By allowing selection of input entries,
and outputting them to
stdout, tquery can be used in combination
with other programs. Below are some useful examples.
Sytem-wide file search
tquery -s -a -- plocate --literal --ignore-case -- | xargs --open-tty vim
Regex path search
tquery -s -- find . -ipath | xargs --open-tty vim
Local line search
tquery -s -- grep -rn . -e | cut -d':' -f1 | xargs --open-tty vim