Shell Highlighting – Using the ‘Highlight’ Command

colorshighlightingshelltext processing

Is there a command which can be used to easily highlight (with colors, bold text or inverted back-/foreground) specific strings in stdin while passing the entire string to stdout? I'm thinking of building it, but I'd rather just use it if it already exists. Some desirable features:

  1. Separate highlight strings are highlighted differently, in an automatic way. For example, the first string will be highlighted in red, the second in green, the third in blue without manual configuration.
  2. Detects color support and falls back to bold/inverted/other highlighting methods where those are available.
  3. Allow for matching of regular expressions and literal strings.
  4. Preferably does something smart if the matches overlap, such as "foobar" and "barbar".
  5. Nothing is modified between stdin and stdout except for the addition of color codes.

Best Answer

Maybe Radovan GarabĂ­k's Generic Colouriser (grc)? It expects a config file as argument and works with regexp's. So not quite without configuration, but you can use process process substitution (<(list)), so by all means without manual configuration :-)