Giter Site home page Giter Site logo

alocate's Introduction

alocate

alocate (approximate locate) is an implementation of locate that can use approximate regex matching to locate files. This means you can locate files named something close to what you remember, or with typos. It is to locate what agrep is to grep.

https://github.com/chazomaticus/alocate

About

alocate is based on the excellent mlocate implementation of locate, using TRE's excellent approximate regex matching functionality. In fact, all I've done is replaced mlocate's regex matching with calls to TRE, and added command line options to expose TRE's matching parameters. This unfortunately means you have to use locate --max-cost=x --regex thing or something equally longwinded to see the effect.

I created the upstream branch from mlocate's mercurial repo (http://hg.fedorahosted.org/hg/mlocate) using git-hg.

Building

I'm going to assume here that you're running Ubuntu, because I am. mlocate is already installed and set up on your system, which will let you easily run out of the build directory.

Install the libtre-dev package. You also may need autopoint and libtool, if you didn't have them already.

Follow the instructions in HACKING. It's more complicated than it should be, but I couldn't get it to build any other way.

Run configure, pointing the locate binary to your existing database:

./configure --localstatedir=/var/lib

Then it should make without issue, and you can run ./locate out of the src directory without installing anything.

Running

Since I've merely replaced mlocate's regex matching with calls to TRE, you need to run locate with --regexp or --regex to invoke any approximate matching. The default max cost (how far off the matched file can be from the supplied pattern) is 0, so you'll also want to pass --max-cost as something higher than 0 to enable non-exact matches.

Here's a breakdown of the command line options I've added:

  • --cost-delete, --cost-insert, --cost-substitute - set the costs of missing, extra, and wrong characters in filenames from the specified pattern (default for each is 1)
  • --max-cost - set the maximum cost for a filename to be considered a match of the specified pattern (default is 0, meaning exact match)
  • --show-cost - print the cost and a : before each matched filename

Future Plans

There's probably lots more that could be done to make this much more useful. Right now it's mostly a proof of concept. See alocate's issues for some ideas.

That said, I don't think I'll be actively working on this any time in the near future. I hope you find it useful as a base for something great, though.

Enjoy!

alocate's People

Contributors

mtrmac avatar chazomaticus avatar atodorov avatar antifa-n avatar kmilos avatar piotrdrag avatar perplesso82 avatar nippur14 avatar diegobz avatar glezos avatar igorpsoares avatar iannsp avatar pcordes avatar taylon avatar fabaff avatar mostafadaneshvar avatar renaultr42 avatar zoltanh721 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.