Skip to content

mle86/hi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hi(1) - highlights lines containing keywords

Build Status GPLv3 License

Version 2.1.0, February 2019

hi [-l|-w|-p] [OPTIONS] [--] KEYWORD...
hi -L [OPTIONS] [--] RANGE...

Description

hi reads text from the standard input and prints its input on the standard output. Lines containing at least one of the given keywords will be colorized with ANSI escape codes.

Installation

$ make
# make install

This will compile the binary and copy it to /usr/local/bin/hi. The man page will be copied to /usr/local/share/man/man.1/hi.1.gz.

Modes

The program operates in one of several output modes.
The default output mode is -l.

  • -l, --lines
    Highlight lines: All lines containing at least one of the KEYWORDs will be highlighted in the output.
  • -p, --paragraphs
    Highlight paragraphs: All paragraphs containing at least one of the KEYWORDs will be highlighted in the output.
  • -w, --words
    Highlight words: Only the KEYWORDs themselves will be colorized in the output.
  • -L, --explicit, --ranges
    Explicit mode: In this mode, there are no KEYWORDs. Instead, the program takes one or more line number RANGEs which will be colorized. For example, the invocation “hi -L 3 8-10 5” will highlight lines 3, 5, 8, 9, and 10 but nothing else. Line numbers start at 1.

Options

  • -i, --ignore-case
    Enable case-insensitive matching. This is the default. Note that the program is unaware of locales and can only compare plain ASCII letters (A..Z) case-insensitively; all other characters will be compared byte-for-byte.
  • -I, --case-sensitive
    Enable case-sensitive matching. The opposite of -i.
  • -c, --color COLOR
    Select the output highlighting color. Recognized colors are:
    • yellow/ye/yw (default),
    • red/re/rd,
    • blue/bl,
    • green/gr/gn,
    • cyan/cy/cn,
    • white/wh.
  • -h, --help
    Show program help.
  • -V, --version
    Show program version information.

License

This program is released under the GPLv3 license.

It includes the "nstr" module from the csv-parser project which is released under the MIT license.

Author

Maximilian Eul <[email protected]> (https://github.com/mle86)