Skip to content

ketralnis/fts

Repository files navigation

a command-line full-text search engine

Quickstart
----------

add it to your $PATH and run like

    $ fts --init # creates .fts.db in the current directory and index everything underneath it
    $ fts bacon  # find "bacon" in files in the current directory

Whenever files have changed:

    $ fts --sync

Searching
---------

Syntax is sqlite's fts4 query language (http://www.sqlite.org/fts3.html)

    $ fts 'sqlite AND database'

Also supported are regex queries. The regex engine is python's re module
(http://docs.python.org/2/library/re.html)

    $ fts --re 'create( virtual)? table'

If you use regex searching, consider installing `re2`
(http://code.google.com/p/re2/ + http://pypi.python.org/pypi/re2/), as fts will
use it if present

Other commands
--------------

    # sync the database state with the disk state (must be done when files are changed)
    $ fts --sync

    # ignore various types of files (you'll want to --sync afterwards)
    $ fts --ignore-re '\.git/objects/[A-Za-z0-9]$'
    $ fts --ignore-glob '*.pyc'
    $ fts --ignore-simple '.svn'
    $ fts --ignore-simple 'corefile'
    $ fts --list-ignores
    $ fts --rm-ignore 1 # stop ignoring this type

    # optimize the database after lots of writes have occurred
    $ fts --optimize

See also `fts --help`

Most commands can be combined. To --init a new database and search it
immediately:

    $ fts --init --ignore-glob='*.pyc' 'what to wear?'

Or to ignore object files and immediately remove them from the database and
defragment it:

    $ fts --ignore-glob '*.o' --sync --optimize

Exit codes
----------

0: there were no errors. if a search was run, at least one result was found
1: there was an error
2: a search was run and no results were found
Other: an unhandled internal error occurred

About

a command-line full-text search tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published