Unreasonably faster notes, with command-line fuzzy search

A good note system should act like a second brain:

  1. Accessible in seconds
  2. Adding information should be frictionless
  3. Searching should be exhaustive – if it’s there, you must find it

The benefits of such a note system are immense – never forget anything again! Search, perform the magic ritual of Copy Paste, and rejoice in the wisdom of your tried and tested past.

But how? Through the unreasonable effectiveness of interactive fuzzy search. This is how I have used Fuz, a terminal-based file fuzzy finder, for about 4 years.

Briefly, Fuz extracts all text within a directory using ripgrep, enables interactive fuzzy search with FZF, and returns you the selected item. As you type, the search results get narrowed down to a few matches. Files are opened at the exact line you found. And it’s FAST – 100,000 lines in half a second fast.

Using Fuz to quickly add a code-snippet in our note directory – then retrieving it with fuzzy-search. Here, on how to read FASTA files with Biopython, conveniently added to a file called biopython.py.

There are also a few other convenient features. Files are searched from memory when available, there is syntax highlighting for markdown and e.g. Python code (using bat), and it’s clever enough to ignore binary, hidden and .gitignore files.

Here is how to install and use Fuz, from https://github.com/Magnushhoie/fuz

# Download and install Fuz
git clone https://github.com/Magnushhoie/fuz/
cd fuz && chmod +x fuz
./fuz --setup
# Requirements (Pick one)

# 1. MacOS, using brew: https://brew.sh/
brew install fzf rg bat

# 2. Any OS, using conda: https://conda.io/docs/user-guide/install/
conda install -c conda-forge fzf ripgrep bat 

# 3. Ubuntu
sudo apt-get install fzf ripgrep
sudo apt install bat
mkdir -p ~/.local/bin
ln -s /usr/bin/batcat ~/.local/bin/bat

By default, Fuz searches the current directory up to 3 levels down, but this can be modified to any depth. It can be immensely useful for finding text across a code-base, or every mention of something across all your projects. Here are a few useful options:

  • fuz: Search text in current directory, (3) levels down
  • fuz --path: Search a specific directory
  • fuz --names: Search file-names
  • fuz --edit: Open file using vim
  • fuz --open: Open file using the system default application

The --setup flag adds a few handy aliases to your ~/.bashrc or ~/.zshrc file, pointing Fuz to a specific directory (see example in the gif above). For example, you may point Fuz to a directory where you keep text notes (e.g. Obsidian, Roam), or a collection of code/project files you want available at your fingertips.

You can have as many files and directories as you wish. Just try to mark your entries with memorable patterns such as __biopython how to read FASTA files__, and you’ll find them in seconds – regardless of where they’re located.

Good luck, and may your second brain grow limited by no bounds!

(And lastly – a short list of related tools you may want to check out)

Author