The highlight package

[Tags:benchmark, bsd3, library, program, test]

Please see README.md.


[Skip to Readme]

Properties

Versions 0.1.0.0, 1.0.0.0, 1.0.0.1
Dependencies ansi-terminal (>=0.6), base (>=4.7 && <5), base-compat (>=0.8), bytestring (>=0.9), containers (>=0.5), directory (>=1.2), filepath (>=1), highlight, lens (>=3), mtl (>=2.0), mtl-compat (>=0.2), optparse-applicative (>=0.11), pipes (>=4), pipes-bytestring (>=2), pipes-group (>=1), pipes-safe (>=2), regex (>=0.10), regex-with-pcre (>=1.0), semigroups (>=0.15), system-filepath (>=0.4), text (>=1.2), transformers (>=0.2), transformers-compat (>=0.3), unix (>=2.0), Win32 (>=2.0) [details]
License BSD3
Copyright 2017 Dennis Gosnell
Author Dennis Gosnell
Maintainer cdep.illabout@gmail.com
Category Text
Home page https://github.com/cdepillabout/highlight
Source repository head: git clone git@github.com:cdepillabout/highlight.git
Uploaded Sat Jul 1 02:05:20 UTC 2017 by cdepillabout
Distributions NixOS:1.0.0.1, Stackage:1.0.0.1
Downloads 99 total (99 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2017-07-01 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for highlight

Readme for highlight-1.0.0.1

Highlight

Build Status Hackage Stackage LTS Stackage Nightly BSD3 license

highlight is a command line program for highlighting parts of a file matching a regex.

For example, take a look at the following file:

non-highlighted file

highlight can be used to highlight the regex cat:

simple highlighted file

Uses

This package installs two binaries, highlight and hrep. The following section explains the main uses of highlight and hrep.

highlight

highlight is used to highlight a given regex in a file, while printing out all lines of the file.

The short example above show how to use highlight to highlight a regex in a single file. It is also possible to use highlight on multiple files at once:

multiple highlighted files

highlight will color and stripe the filenames to make it easier to see which line came from which file. This also shows an example of the --ignore-case option, which is similar to grep's --ignore-case option.

highlight output from grep

highlight has a special option for highlighting output from grep:

highlight from grep

This --from-grep option will color and stripe filenames, similar to the previous example.

hrep

With the previous --from-grep option to highlight, one unfortunate point is that the regex has to be specified twice, once to grep and once to highlight.

The hrep command can solve this for us. It is just like the grep command, but it will color and stripe filenames:

hrep example

Installation

highlight and hrep can be installed with stack:

$ stack install highlight

It should also be possible to use cabal to install this package.

Other ways to highlight parts of files

It is possible to highlight lines matching a given regex with grep two different ways.

  1. Use a special regex that will match any line, but only highlight the part desired. It would look like this:

    $ grep 'about|$' file-cats file-dogs file-goats
    
  2. Give a large --context flag:

    $ grep --context 9999 'about' file-cats file-dogs file-goats
    

However, neither of these will color and stripe filenames.

Contributions

Feel free to open an issue or PR for any bugs/problems/suggestions/improvements.

Additional flags

highlight and hrep do not currently support all flags and options that grep does. Ideally, highlight and hrep would be drop-in replacements for grep, supporting all the same flags and options as grep.

If there is a flag or option you frequently use and want supported with highlight or hrep, please feel free to open an issue or PR. Some flags/options will be relatively easy to support, while some may require quite a large amount of additional code.