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.6.tar.gz (30.7 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.6-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: offgrep-0.3.6.tar.gz
  • Upload date:
  • Size: 30.7 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.6.tar.gz
Algorithm Hash digest
SHA256 de6e6629bd9998e1b18f6a68525cd1fd142ed91601c567dd4a90842234ed5ad3
MD5 0f531845e1fe50bc73a7b18724f6b395
BLAKE2b-256 8c629175e47ef8a2aeb639870debec7094cdb86fbf8f19f2529f4e9a3b17be8e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: offgrep-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 35.7 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8a22bf4245de3f09a2672744d8c9bc1eb47f612c2306839da431990c8e053805
MD5 f9edd49e992a1bf798f9c7443a04b596
BLAKE2b-256 b23b2429cc3066a238ca4cbc9d506b7ecc87c1af727b7459ace2149cd316d352

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.7

2 files

This release

0.3.6 This release

2 files

0.3.5

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