{"id":13502932,"url":"https://github.com/rhysd/hgrep","last_synced_at":"2025-05-14T19:07:29.727Z","repository":{"id":38847409,"uuid":"416368107","full_name":"rhysd/hgrep","owner":"rhysd","description":"Grep with human-friendly search results","archived":false,"fork":false,"pushed_at":"2025-03-05T11:11:01.000Z","size":5472,"stargazers_count":474,"open_issues_count":2,"forks_count":9,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-13T15:06:56.510Z","etag":null,"topics":["bat","grep","pretty-print","ripgrep","syntax-highlighting"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhysd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-12T14:21:39.000Z","updated_at":"2025-04-11T18:38:31.000Z","dependencies_parsed_at":"2024-01-18T11:45:48.476Z","dependency_job_id":"e9335b8c-d509-4be6-8c7d-227d4d1d8d8a","html_url":"https://github.com/rhysd/hgrep","commit_stats":{"total_commits":515,"total_committers":6,"mean_commits":85.83333333333333,"dds":0.05242718446601946,"last_synced_commit":"95ccd291343ba91676c8c146005b53221c61631d"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fhgrep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fhgrep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fhgrep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fhgrep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhysd","download_url":"https://codeload.github.com/rhysd/hgrep/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254209859,"owners_count":22032897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bat","grep","pretty-print","ripgrep","syntax-highlighting"],"created_at":"2024-07-31T22:02:30.833Z","updated_at":"2025-05-14T19:07:28.386Z","avatar_url":"https://github.com/rhysd.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"hgrep: Human-friendly GREP\n==========================\n[![CI][ci-badge]][ci]\n[![crate][crates-io-badge]][crates-io]\n[![Coverage][codecov-badge]][codecov]\n\n[hgrep][] is a grep tool to search files with a given pattern and print the matched code snippets with human-friendly syntax\nhighlighting. This tool brings search results like the code search on GitHub to your local machine. In short, it's something like\nsearching files with [ripgrep][] and showing results with [bat][].\n\nThis is similar to `-C` option of `grep` command. hgrep is useful to survey the matches with contexts around them. When some\nmatches are near enough, hgrep prints the lines within one code snippet. Unlike `grep -C`, hgrep adopts some heuristics around\nblank lines to determine an efficient number of context lines.\n\n\u003cimg src=\"https://github.com/rhysd/ss/raw/master/hgrep/main.png\" alt=\"screenshot\" width=\"682\" /\u003e\n\nExample:\n\n```sh\n# Use built-in subset of ripgrep (optional)\nhgrep pattern ./dir\n\n# Read results of grep command via stdin\ngrep -nH pattern -R ./dir | hgrep\nrg -nH pattern ./dir | hgrep\n```\n\nhgrep provides two printers to print match results for your use case. Please see ['`bat` printer v.s. `syntect` printer'][bat-vs-syntect]\nsection for the comparison.\n\n- `syntect` printer (default): Our own implementation of printer using [syntect][] library. Performance, output layout, and color\n  themes are more optimized\n- `bat` printer: Printer built on top of [bat][]'s pretty printer implementation, which is battle-tested and provides some unique\n  features\n\nPlease see [the usage section](#usage) for more details.\n\n## Installation\n\n### Binary releases\n\nVisit [the releases page][releases] and download the zip file for your platform. Unarchive the file and put the executable file\nin some `$PATH` directory. Currently, the following targets are supported. If you want a binary for some other platform, feel free\nto make an issue to request it.\n\n- Linux (x86_64-gnu, x86_64-musl, aarch64-gnu)\n- macOS (x86_64, aarch64)\n- Windows (x86_64-msvc)\n\n### Via [Homebrew][homebrew]\n\nBy adding hgrep repository as Homebrew tap, `hgrep` command can be installed and managed via Homebrew. [The formula][formula]\nsupports x86_64/aarch64 macOS and x86_64 Linux.\n\n```sh\nbrew tap \"rhysd/hgrep\" \"https://github.com/rhysd/hgrep\"\nbrew install hgrep\n```\n\nNote: If you installed Homebrew to a non-default location (e.g. `~/homebrew`), you might see some errors. In the case, please try\nto install `hgrep` via [cargo][] instead. See [#6][issue-6] for more details.\n\n### Via [MacPorts][macports]\n\nOn macOS, you can install `hgrep` with the following commands through MacPorts:\n\n```sh\nsudo port selfupdate\nsudo port install hgrep\n```\n\n### For NetBSD\n\nTo install pre-built binaries using the package manager, simply run:\n\n```sh\npkgin install hgrep\n```\n\nOr, if you prefer to build from source,\n\n```sh\ncd /usr/pkgsrc/textproc/hgrep\nmake install\n```\n\n### Via [APT][apt] package manager on Debian or Ubuntu\n\nVisit [the releases page][releases] and download `.deb` package file. It can be installed via `dpkg` command:\n\n```sh\nsudo dpkg -i hgrep_v0.3.6-1_amd64.deb\n```\n\nThe manual (for `man` command) and Bash completion is automatically installed. If you're using some other shell, setup the shell\ncompletion by yourself. See ['Generate completion scripts' section](#gen-completion-scripts) for more details.\n\n### Via [cargo][] package manager\n\n```sh\ncargo install hgrep\n```\n\nSince `cargo` builds `hgrep` command from sources, you can choose your favorite features and drop others by feature flags. For\nexample, if you always use `hgrep` with reading `grep` output from stdin and don't use `bat` printer, only enabling `syntect-printer`\ndramatically reduces the number of dependencies, installation time, and binary size.\n\n```sh\ncargo install hgrep --no-default-features --features syntect-printer\n```\n\n### Feature flags\n\nAll features are optional and enabled by default. At least `bat-printer` or `syntect-printer` needs to be enabled.\n\n| Feature           | Description                                                                                                                   |\n|-------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `ripgrep`         | Built-in grep implementation built on top of [ripgrep][] as a library. Performance is better than piping `rg` in some cases.  |\n| `syntect-printer` | Our own printer implementation built with [syntect][] library. Performance and output layout are optimized for our use cases. |\n| `bat-printer`     | Printer implementation built on top of [bat][]'s pretty printer, which is battle-tested and provides some unique features.    |\n\nFor the differences of `bat-printer` and `syntect-printer`, see ['`bat` printer v.s. `syntect` printer'][bat-vs-syntect] section.\n\n## Usage\n\n### Built-in ripgrep\n\nOptionally hgrep provides built-in grep implementation thanks to [ripgrep][] as a library. It is a subset of `rg` command.\n\nBuilt-in ripgrep is a recommended way to use hgrep because it is optimized for the use case.\n\nWhen a pattern is given, `hgrep` command search files in given paths with it. When a directory is included in paths, hgrep\nsearches it recursively. When no path is given, hgrep searches the current directory.\n\n```sh\nhgrep [options...] pattern [paths...]\n```\n\nBy default, hgrep shows at least 3 lines and at most 6 lines as context of a match. How many context lines is determined by some\nheuristics around blank lines for space efficiency. Minimum context lines can be specified by `-c` and maximum context lines can\nbe specified by `-C`. If you don't want the heuristics, give the same value to the options like `-c 6 -C 6`.\n\n```sh\n# At least 10 context lines and at most 20 context lines\nhgrep -c 10 -C 20 pattern paths...\n```\n\nLike ripgrep, the built-in grep filters files by default. It looks at ignore files such as `.gitignore` and ignores hidden files.\nTo disable the filters, `--no-ignore` and `--hidden` are available respectively. `-u` is a useful shortcut for them.\n\n```sh\n# Same as `hgrep --no-ignore pattern paths...`\nhgrep -u pattern paths...\n\n# Same as `hgrep --no-ignore --hidden pattern paths...`\nhgrep -uu pattern paths...\n```\n\nRegarding to the performance compared to receiveing inputs from `grep` or `rg` via pipe, it's fast to handle so many matches in\nthe same process. In combination with `syntect-printer` feature, matched regions can be highlighted in a searched text color.\nThe built-in grep feature is enabled by default and can be omitted by feature flags.\n\nThough almost all useful options are implemented, the built-in grep implementation is a subset of ripgrep. If you need full\nfunctionalities, use `rg` command and eat its output by hgrep via stdin. Currently there are the following restrictions.\n\n- Preprocessor is not supported (e.g. search zip files)\n- Pattern file (`-f` or `--file` of `rg`) is not supported\n- Sorting results (`--sort` and `--sortr`) is not supported because it significantly slows down printing the search output\n- Memory map is not used until `--mmap` flag is specified\n- Adding and removing file types are not supported. Only default file types are supported (see `--type-list`)\n- `.ripgreprc` config file is not supported\n- Searching binary files (`--binary`) is not supported\n\n### Eating `grep -nH` output\n\nWhen no pattern and paths are given in command line arguments, hgrep can take grep results via stdin. Since hgrep expects file\npaths and line numbers in each line of the output, `-nH` is necessary at `grep` command.\n\n```sh\ngrep -nH pattern -R paths... | hgrep [options...]\n```\n\n`grep` alternative tools like [ripgrep][], [ag][], [pt][], ... are also available because they can output results compatible with\n`grep -nH`.\n\n```sh\nrg -nH pattern paths... | hgrep [options...]\n```\n\n### `bat` printer v.s. `syntect` printer\n\nhgrep provides two printers to print match results; `bat` printer and `syntect` printer. `bat` printer is a printer\nimplementation built on top of [bat][]'s pretty printer. And `syntect` printer is our own printer implementation built with\n[syntect][] library. `--printer` (or `-p`) flag can specify the printer to print results.\n\nAt first, there was `bat` printer only. And then `syntect` printer was implemented for better performance and optimized layout.\n\n#### Pros of each printers\n\n- `syntect` printer\n  - Performance is much better. 2x to 4x faster (more match results get better performance).\n  - Output layout is optimized for our use cases. Matched regions are highlighted in a searched text color. A line number at a\n    match is highlighted in a different color.\n  - Painting background color (`--background`) is supported. This is useful when your favorite theme does not fit to your\n    terminal's background color.\n  - Themes are optimized for showing matched results. And some new themes like [ayu][] or [predawn][] are available. See the\n    output of `--list-themes` to know the list of all themes.\n  - Compatibility for old terminals is better. It automatically changes the default theme to 'ansi' for 16-colors terminals. And\n    it provides `--ascii-lines` flag to draw border lines with ascii characters instead of Unicode characters like '├', '┬', and\n    so on.\n- `bat` printer\n  - Implementation is battle-tested. It is already used by many users on many platforms and terminals.\n  - The behavior is compatible with `bat` command. Its output layout is the same as `bat` command respecting `BAT_THEME` and\n    `BAT_STYLE` environment variables. It can load bat's custom assets cache.\n\n`syntect` is the default printer.\n\n#### Themes only available with `syntect` printer\n\n| ayu-dark | ayu-mirage | ayu-light |\n|----------|------------|-----------|\n| ![ayu-dark](https://github.com/rhysd/ss/blob/master/hgrep/ayu-dark.png?raw=true) | ![ayu-mirage](https://github.com/rhysd/ss/blob/master/hgrep/ayu-mirage.png?raw=true) | ![ayu-light](https://github.com/rhysd/ss/blob/master/hgrep/ayu-light.png?raw=true) |\n\n| Cyanide | predawn | Material |\n|---------|---------|----------|\n| ![cyanide](https://github.com/rhysd/ss/blob/master/hgrep/cyanide.png?raw=true) | ![predawn](https://github.com/rhysd/ss/blob/master/hgrep/predawn.png?raw=true) | ![cyanide](https://github.com/rhysd/ss/blob/master/hgrep/material.png?raw=true) |\n\n(and more...)\n\n#### Why performance of `syntect` printer is better?\n\nSyntax highlighting is very CPU-heavy task. Many regular expression matchings happen at each line. For accurate syntax\nhighlighting, a highlighter needs to parse the syntax from the beginning of file. It means that printing a match at the last\nline of a file is a much heavier task than printing a match at the first line of the file.\n\nSince `syntect` printer is designed for calculating syntax highlights per file in parallel, its performance is much better. It's\n2x~4x faster than `bat` printer in some experiments. More match results get better performance.\n\nIn contrast, bat is not designed for multi-threads. It's not possible to share `bat::PrettyPrinter` instance across threads. It\nmeans that printing match results including syntax highlighting must be done in a single thread.\n\n| `syntect` printer sequence | `bat` printer sequence |\n|----------------------------|------------------------|\n| ![](https://github.com/rhysd/ss/raw/master/hgrep/comparison_syntect.png) | ![](https://github.com/rhysd/ss/raw/master/hgrep/comparison_bat.png) |\n\n### Using pager\n\nWhen you want a pager to see the output interactively, please pipe the output to external commands like `less`. `$COLUMNS` needs\nto be passed to `--term-width` option because the terminal width is fixed to 80 characters when stdout is not connected to TTY.\nIf you frequently use a pager, it is a good option to define a wrapper shell function like below:\n\n```sh\nfunction hgrep() {\n    command hgrep --term-width \"$COLUMNS\" \"$@\" | less -R\n}\n```\n\n### Change color theme and layout\n\nThe default color theme is `Monokai Extended` respecting `bat` command's default. Other theme can be specified via `--theme`\noption. To know names of themes, try `--list-themes` flag.\n\n```sh\nhgrep --theme Nord ...\n```\n\nThe default layout is 'grid'. To reduce borderlines to use space more efficiently, `--no-grid` option is available.\n\n```sh\nhgrep --no-grid ...\n```\n\nWhen you use `bat` printer, hgrep respects `BAT_THEME` and `BAT_STYLE` environment variable. Theme set to `BAT_THEME`\nis used by default. And the grid layout is used when `plain` or `header` or `numbers` is set to `BAT_STYLE`. `syntect`\nprinter does not look at these variables. To set default theme, please use a command alias in your shell (See\n['Set default command options'](#set-default-command-options) for details).\n\n```sh\nexport BAT_THEME=OneHalfDark\nexport BAT_STYLE=numbers\nhgrep -p bat ...\n```\n\nWhen `syntect` printer is used, painting background colors is supported with `--background` flag.\n\n```sh\nhgrep --background ...\n```\n\n### Set default command options\n\n`HGREP_DEFAULT_OPTS` environment variable is available. Options set to the variable are prepended to the command line arguments\nwhen you run `hgrep` command.\n\nHere are some examples:\n\n```sh\n# Set the `ayu-dark` color theme with background colors\nexport HGREP_DEFAULT_OPTS='--theme ayu-dark --background'\n# Same as `hgrep --theme ayu-dark --background pattern paths`\nhgrep pattern paths...\n\n# Disable automatic filtering\nexport HGREP_DEFAULT_OPTS='--no-ignore --hidden'\n\n# Use 'bat' printer by default\nexport HGREP_DEFAULT_OPTS='--printer bat'\n```\n\nThe command line arguments in the environment variable are parsed with [shlex][]. Use quotes for including spaces in some command\nline option arguments. For example:\n\n```pwsh\n$Env:HGREP_DEFAULT_OPTS = \"--glob '!C:\\Program Files'\"\n```\n\n### Command options\n\n- Common options\n  - `--min-context NUM` (`-c`): Minimum lines of leading and trailing context surrounding each match. Default value is 3\n  - `--max-context NUM` (`-C`): Maximum lines of leading and trailing context surrounding each match. Default value is 6\n  - `--no-grid` (`-G`): Remove borderlines for more compact output. --grid flag is an opposite of this flag\n  - `--tab NUM`: Number of spaces for tab character. Set 0 to pass tabs through. Default value is 4\n  - `--theme THEME`: Theme for syntax highlighting. Default value is the same as `bat` command\n  - `--list-themes`: List all available theme names and their samples for --theme option\n  - `--printer`: Printer to print the match results. 'bat' or 'syntect' is available. Default value is 'bat'\n  - `--term-width NUM`: Width (number of characters) of terminal window\n  - `--wrap MODE`: Text-wrapping mode. 'char' enables character-wise text-wrapping. 'never' disables text-wrapping. Default value is 'char'\n  - `--first-only` (`-f`): Show only the first code snippet per file\n  - `--encoding` (`-E`): Specify the text encoding that hgrep will use on all files printed like 'sjis'\n- Only for `ripgrep` feature\n  - `--no-ignore`: Don't respect ignore files (.gitignore, .ignore, etc.)\n  - `--ignore-case` (`-i`): When this flag is provided, the given pattern will be searched case insensitively\n  - `--smart-case` (`-S`): Search case insensitively if the pattern is all lowercase. Search case sensitively otherwise\n  - `--hidden` (`-.`): Search hidden files and directories. By default, hidden files and directories are skipped\n  - `--unrestricted` (`-u`): Reduce the level of \"smart\" filtering by repeated uses (up to 2). A single flag `-u` is equivalent to --no-ignore.\n    Two flags `-uu` are equivalent to --no-ignore --hidden. Unlike ripgrep, three flags `-uuu` are not supported since hgrep doesn't support\n    --binary flag\n  - `--glob GLOB...` (`-g`): Include or exclude files and directories for searching that match the given glob\n  - `--glob-case-insensitive`: Process glob patterns given with the -g/--glob flag case insensitively\n  - `--fixed-strings` (`-F`): Treat the pattern as a literal string instead of a regular expression\n  - `--word-regexp` (`-w`): Only show matches surrounded by word boundaries\n  - `--follow` (`-L`): When this flag is enabled, hgrep will follow symbolic links while traversing directories\n  - `--multiline` (`-U`): Enable matching across multiple lines\n  - `--multiline-dotall`: Enable \"dot all\" in your regex pattern, which causes '.' to match newlines when multiline searching is enabled\n  - `--crlf`: When enabled, hgrep will treat CRLF (`\\r\\n`) as a line terminator instead of just `\\n`. This flag is useful on Windows\n  - `--mmap`: Search using memory maps when possible. mmap is disabled by default unlike hgrep\n  - `--max-count NUM` (`-m`): Limit the number of matching lines per file searched to NUM\n  - `--max-depth NUM`: Limit the depth of directory traversal to NUM levels beyond the paths given\n  - `--max-filesize NUM+SUFFIX?`: Ignore files larger than NUM in size. This does not apply to directories.The input format accepts suffixes of K, M or G\n  - `--line-regexp` (`-x`): Only show matches surrounded by line boundaries. This is equivalent to putting `^...$` around the search pattern\n  - `--invert-match` (`-v`): Invert matching. Show lines that do not match the given pattern\n  - `--pcre2` (`-P`): When this flag is present, hgrep will use the PCRE2 regex engine instead of its default regex engine\n  - `--type TYPE` (`-t`): Only search files matching TYPE. This option is repeatable\n  - `--type-not TYPE` (`-T`): Do not search files matching TYPE. Inverse of --type. This option is repeatable\n  - `--type-list`: Show all supported file types and their corresponding globs\n  - `--one-file-system`: When enabled, the search will not cross file system boundaries relative to where it started from\n  - `--no-unicode`: Disable unicode-aware regular expression matching\n  - `--regex-size-limit NUM+SUFFIX?`: The upper size limit of the compiled regex. The default limit is 10M. For the size suffixes, see --max-filesize\n  - `--dfa-size-limit NUM+SUFFIX?`: The upper size limit of the regex DFA. The default limit is 10M. For the size suffixes, see --max-filesize\n- Only for `syntect-printer` feature\n  - `--background`: Paint background colors. This is useful when your favorite theme does not fit to your terminal's background color\n  - `--ascii-lines`: Use ASCII characters for drawing border lines instead of Unicode characters\n- Only for `bat-printer` feature\n  - `--custom-assets`: Load bat's custom assets from cache. Note that this flag may not work with some version of `bat` command\n\nSee `--help` for the full list of available options in your environment.\n\n### Text encoding\n\nhgrep supports various encodings thanks to [`encoding_rs` crate][encoding_rs].\n\n`--encoding` (`-E`) command line option can specify the file encoding explicitly. For example, the following command will assume\nmatched files are encoded with Shift JIS.\n\n```sh\nhgrep --encoding sjis pattern\n```\n\nIn addition, hgrep tries to detect file encodings from [BOM][bom]. UTF-16LE, UTF-16BE, and UTF-8 can be detected automatically.\n\nWhen no file encoding is detected from BOM, hgrep assumes files are encoded in UTF-8 as default encoding. If malformed UTF-8\nsequences are contained, they are replaced with the replacement character `U+FFFD`.\n\n\u003ca name=\"gen-completion-scripts\"\u003e\u003c/a\u003e\n### Generate completion scripts\n\nShell completion script for `hgrep` command is available. `--generate-completion-script` option generates completion script and\nprints it to stdout. [Bash][bash], [Zsh][zsh], [Fish][fish], [PowerShell][pwsh], [Elvish][elvish], [Nushell][nushell] are\nsupported. See `--help` for more details.\n\nHere is an example of setup the completion script on Zsh.\n\n```sh\n# Let's say we set comps=~/.zsh/site-functions\nhgrep --generate-completion-script zsh \u003e ~/.zsh/site-functions/_hgrep\nchmod +x ~/.zsh/site-functions/_hgrep\n```\n\n### Generate man page\n\nManual page for `hgrep` command is available. `--generate-man-page` flag generates the man page and prints it to stdout.\n\nThis is an example to generate man page in `/usr/local/share`.\n\n```sh\nhgrep --generate-man-page \u003e /usr/local/share/man/man1/hgrep.1\n\n# See the manual page\nman hgrep\n```\n\n### Exit status\n\n`hgrep` command returns the exit status as follows.\n\n| Status | Description                         |\n|--------|-------------------------------------|\n|   0    | One or more matches were found      |\n|   1    | No match was found                  |\n|   2    | Some error happened (e.g. IO error) |\n\n### Terminal color support detection\n\nhgrep automatically detects 24-bit or 256 or 16 colors support of your terminal application by the following logic.\n\n#### `COLORTERM`\n\nAt first, hgrep checks [`COLORTERM` environment variable][term-caps]. When `truecolor` or `24bit` is set to the variable, 24-bit\ncolors are enabled.\n\nOn Linux or macOS or FreeBSD or NetBSD, hgrep tries to detect your terminal's color support from [terminfo][].\n\nOn Windows, hgrep enables 24-bit colors if the Windows version is 10.0.15063 or later becuase\n[OS version 10.0.15063 (Windows 10 1703) started to support 24-bit colors][rich-issue-140]. Otherwise it enables only 16-colors.\n\n#### `TERM`\n\nWhen `COLORTERM` is not set, hgrep checks [`TERM` environment variable][term-caps] which the terminal name is set.\n\n- When it ends with `-truecolor` or `-24bit`, 24-bit colors are enabled.\n- When it ends with `-256color` or `-square`, 256 colors are enabled.\n\n#### Fallback\n\nWhen no color support was detected from `COLORTERM` nor `TERM`, htrep eventually falls back to 256 colors, which are most widely\nsupported by popular terminals.\n\n## Versioning\n\nAt this point the major version is fixed to 0. The minor version is bumped when some breaking changes are added. The patch\nversion is bumped when some new compatible changes are added and/or some bug fixes are added.\n\n## Alternatives\n\nSome other alternatives instead of using hgrep.\n\n### Small ShellScript to combine `ripgrep` and `bat`\n\nripgrep and bat are well-designed tools so they can be used as building parts of a small script.\n\n```sh\nrg -nH ... | while IFS= read -r line; do\n  # Parse $line and calculate the range of snippet and highlighted lines\n  file=...\n  lines=...\n  range=...\n\n  # Show matched snippet\n  bat -H ${lines} -r ${range} ${file}\ndone\n```\n\nIt works fine but hgrep is more optimized for this usage.\n\n- When the matches are near enough, the lines are printed in one snippet.\n- Performance is much better than running `bat` process per matched line.\n- hgrep computes efficient context lines based on some heuristics.\n- hgrep is available where ShellScript is unavailable (e.g. PowerShell).\n\n### Fuzzy finder like `fzf` with `bat` preview window\n\nFuzzy finder like [fzf][] provides a preview window functionality and `bat` can print the match in the preview window.\n\n```sh\ngrep -nH ... | \\\n    fzf --preview='bat --pager never --color always -H {2} -r {2}: -p {1}' --delimiter=:\n```\n\nThis usage is great when you need the incremental search, but you need to check each preview of matches one by one.\n\nhgrep focuses on surveying all the matches.\n\n## Bug reporting\n\nPlease [create an issue on GitHub][new-issue]. Ensure to describe how to reproduce the bug.\n\n## License\n\nhgrep is distributed under [the MIT license](./LICENSE.txt).\n\n[hgrep]: https://github.com/rhysd/hgrep\n[ripgrep]: https://github.com/BurntSushi/ripgrep\n[bat]: https://github.com/sharkdp/bat\n[cargo]: https://github.com/rust-lang/cargo\n[ag]: https://github.com/ggreer/the_silver_searcher\n[pt]: https://github.com/monochromegane/the_platinum_searcher\n[fzf]: https://github.com/junegunn/fzf\n[ci-badge]: https://github.com/rhysd/hgrep/actions/workflows/ci.yml/badge.svg\n[ci]: https://github.com/rhysd/hgrep/actions/workflows/ci.yml\n[crates-io]: https://crates.io/crates/hgrep\n[crates-io-badge]: https://img.shields.io/crates/v/hgrep.svg\n[codecov-badge]: https://codecov.io/gh/rhysd/hgrep/branch/main/graph/badge.svg?token=IF41OXFJEQ\n[codecov]: https://codecov.io/gh/rhysd/hgrep\n[releases]: https://github.com/rhysd/hgrep/releases\n[shlex]: https://crates.io/crates/shlex\n[encoding_rs]: https://docs.rs/encoding_rs/latest/encoding_rs/\n[bom]: https://en.wikipedia.org/wiki/Byte_order_mark\n[bash]: https://www.gnu.org/software/bash/\n[zsh]: https://www.zsh.org/\n[fish]: https://fishshell.com/\n[pwsh]: https://docs.microsoft.com/en-us/powershell/\n[elvish]: https://elv.sh/\n[nushell]: https://www.nushell.sh/\n[homebrew]: https://brew.sh/\n[macports]: https://www.macports.org/\n[apt]: https://www.debian.org/doc/manuals/debian-faq/pkgtools.html\n[new-issue]: https://github.com/rhysd/hgrep/issues/new\n[syntect]: https://github.com/trishume/syntect\n[bat-vs-syntect]: #bat-printer-vs-syntect-printer\n[ayu]: https://github.com/dempfi/ayu\n[predawn]: https://github.com/jamiewilson/predawn\n[formula]: ./HomebrewFormula/hgrep.rb\n[issue-6]: https://github.com/rhysd/hgrep/issues/6\n[term-caps]: http://jdebp.uk/Softwares/nosh/guide/TerminalCapabilities.html\n[terminfo]: https://en.wikipedia.org/wiki/Terminfo\n[rich-issue-140]: https://github.com/Textualize/rich/issues/140\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhysd%2Fhgrep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhysd%2Fhgrep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhysd%2Fhgrep/lists"}