A fast locate-like tool that you can carry with you in your dotfiles, that only uses basic binaries available on most systems. Searches through a compressed database of file locations on your hard drive that you can search with "flocate". I called it flocate to avoid conflicts on systems that have a proper installation of locate.

After reading Julia Evans' Post on how locate works and how to make it faster, I wanted to incorporate it into my dotfiles. So, I wrote some shell functions that make it easy to do. I also included gzip compression of the generated find database, on my Macbook it keeps a ~216MB file in the 20MB range, since there's a lot of repeated data.

function fupdatedb() {
    if [ -f /tmp/flocate.db ]; then
        rm /tmp/flocate.db

    find / 2>/dev/null | gzip > /tmp/flocate.db

function flocate() {

    if [ ! -f /tmp/flocate.db ]; then
        echo "flocate.db does not exist: run fupdatedb"
        return -1

    zgrep $1 /tmp/flocate.db --color=auto