Skip to main content

offgrep

A lousy ripgrep rip-off in pure Python

Searches text in a grep-like manner in text files, recursively searching for files from the provided starting-point or from the current working directory.

When doing so, offgrep respects ignore rules in a .gitignore file.

This behavior is a small fraction of ripgrep’s capabilities, combined with a ridiculously low execution speed.

So if you have any chance to run the original, please use ripgrep instead of offgrep.

If you – however – are in a super restricted network (eg. government) without a chance to install ripgrep, but are able to install Python packages, offgrep might be suitable for you.

usage

usage: offgrep [-h] [-V] [--encoding ENCODING] [--verbose | --debug | -q]
               [--hi {.,a,b,c,g,p,r,s,u,y,z} | --red | --green | --yellow |
               --blue | --purple | --cyan | --highlighters] [--stats]
               [--files] [--type-list] [--pre-ignore PATTERNS]
               [--post-ignore PATTERNS] [--ignore-file-case-insensitive]
               [-g PATTERN] [-t FILETYPE] [-T FILETYPE]
               [--glob-case-insensitive] [-d NUM] [-e PATTERN]
               [-f PATTERNFILE] [-F] [-i]

searches text in (text) files recursively

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --encoding ENCODING   Encoding of all files (default: utf-8)

Output options:
  --verbose             log with level INFO
  --debug               log with level DEBUG
  -q, --quiet           no output except for CRITICAL errors
  --hi, --highlight-matches {.,a,b,c,g,p,r,s,u,y,z}
                        Highlight matches with the provided profile. The
                        default is 'z' (no highlighting). Use the
                        --highlighters option for an overview with examples.
  --red                 Highlight matches in red.
  --green               Highlight matches in green.
  --yellow              Highlight matches in yellow.
  --blue                Highlight matches in blue.
  --purple              Highlight matches in purple.
  --cyan                Highlight matches in cyan.
  --highlighters        Show highlighter effects on examples and exit.
  --stats               Collect and show statistics.
  --files               Print the path of each file that would be searched,
                        without actually performing the search.
  --type-list           Print the list of supported file types and exit.

File selection options:
  --pre-ignore PATTERNS
                        gitignore-style patterns for files and/or directories
                        ignored before applying found ignore file rules,
                        joined with commas (,). Defaults to VCS repository
                        directories ('.git/,.hg/,.jj/,.bzr/,_darcs/,.svn/').
  --post-ignore PATTERNS
                        gitignore-style patterns for files and/or directories
                        ignored after applying found ignore file rules, joined
                        with commas (,). Empty by default ('').
  --ignore-file-case-insensitive
                        Process ignore rules (from .gitignore, .ignore, etc,
                        but also those specified directly through --pre-
                        ignore/--post-ignore) case insensitively. Most useful
                        on case insensitive file systems (such as Windows).
  -g, --glob PATTERN    Include or exclude files and directories for searching
                        that match the given glob. This always overrides any
                        other ignore logic. Multiple glob flags may be used.
                        Globbing rules match .gitignore globs. Precede a glob
                        with a ! to exclude it.
  -t, --type FILETYPE   Search only in files of type FILETYPE. May be
                        specified multiple times. See --type-list output for
                        supported file types.
  -T, --type-not FILETYPE
                        Do not search in files of type FILETYPE. May be
                        specified multiple times. See --type-list output for
                        supported file types.
  --glob-case-insensitive
                        Process all glob patterns given with the -g/--glob
                        flag case insensitively.
  -d, --max-depth NUM   limits the depth of directory traversal to &(metavar)s
                        levels beyond the paths given. A value of 0 only
                        searches the explicitlygiven paths themselves.

Pattern matching options:
  -e, --expression PATTERN
                        Pattern (by default, regular exoressions) to search
                        for. May be specified multiple times if you want to
                        search for multiple patterns at once.
  -f, --file PATTERNFILE
                        File containing patterns (by default, regular
                        expressions). May be specified multiple times to use
                        multiple files.
  -F, --fixed-strings   treat the given pattern(s) as fixed strings instead of
                        regular expressions so special characters – .+*()[]{}
                        – do not need to be escaped, also saving some energy.
  -i, --ignore-case     case-insensitive matching

The provided options (or usage in a shell pipeline)
determine how the positional arguments are interpreted:

  (1) offgrep [OPTIONS] PATTERN [PATH ...],
        the first positional argument is interpreted as the pattern,
        the remaining ones as paths.
  (2) offgrep [OPTIONS] -e PATTERN ... [PATH ...]
        all positional arguments are interpreted as paths.
  (3) offgrep [OPTIONS] -f PATTERNFILE ... [PATH ...]
        all positional arguments are interpreted as paths.
  (4) offgrep [OPTIONS] --files [PATH ...]
        all positional arguments are interpreted as paths.
  (5) offgrep [OPTIONS] [--highlighters | --type-list]
        all positional arguments are ignored.
  (6) command | offgrep [OPTIONS] PATTERN
        the first positional argument is interpreted as the pattern,
        and the remaining positional arguments are ignored.
  (7) command | offgrep [OPTIONS] -e PATTERN ...
        all positional arguments are ignored.
  (8) command | offgrep [OPTIONS] -f PATTERNFILE ...
        all positional arguments are ignored.

If no paths were provided as positional arguments in variants 1 through 4,
the current working directory will be used as the starting point.
Variants 6 through 8 show how offgrep can be used as a filter
(ignoring all paths provided as positional arguments).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

offgrep-0.3.5.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

offgrep-0.3.5-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file offgrep-0.3.5.tar.gz.

File metadata

  • Download URL: offgrep-0.3.5.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.5","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for offgrep-0.3.5.tar.gz
Algorithm Hash digest
SHA256 828a910714c5553f0cd99f23ce3d447032b1d8a0744c156d58fe7f970c7508f1
MD5 e8bd71787c73346a589599b3a2e4bf4d
BLAKE2b-256 0bec2a15d479107e811576e10fcafd850a78ac236bf49a87ff4a5c8404f30c62

See more details on using hashes here.

File details

Details for the file offgrep-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: offgrep-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.5","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for offgrep-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 34f644802414bf92d2a6274a2637cbbdacf69e8798c0dda65950f96eb739fcf9
MD5 6f57a218e85ce2694c9da33305cd87eb
BLAKE2b-256 4f66ab75c6e42c82650404f1e5aace9ca0c9f77d3e7d8520a7fca4b51d12fae2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.7

2 files

0.3.6

2 files

This release

0.3.5 This release

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page