0

I have less already displaying colored output (e.g. from Vagrant or Packer) by having the LESS environment variable set to -R.

What I'd like to be able to do now is to search for specific colors, e.g. ESC[1;31m for red.

I tried various combinations (e.g. \[1;31m) but it seems that less ignores them in its search when in -R mode. When I toggle -R off it finds them, though. This could make sense when you think of it because the entire sequence is considered as having "zero width" so there is nothing for less to show when it finds it.

Is there another trick I can use?

To recap - the aim is to keep viewing colored output but also be able to search the color escape sequence at the same time.

Capt. Crunch
  • 839
  • 2
  • 12
  • 25
  • Can't vouch for it, but there is something about this in the [Unix and Linux forum](http://unix.stackexchange.com/questions/149614/less-command-change-color-of-and-end). – Colt May 02 '16 at 01:21
  • @Colt thanks but unfortunately the question you link to is about colorising less' search output, not about finding existing color sequences. :( – Capt. Crunch May 02 '16 at 01:24
  • Ahh, yes, that is what you said! It seems that the `-R` is what is supposed to do this, but it also seems that it is problematic. – Colt May 02 '16 at 01:44
  • 1
    Why do you need this? – ewwhite May 02 '16 at 01:47
  • @ewwhite I want this in order to find errors in command output. e.g. "Puppet" already marks errors in red color. Searching for "Error: " works most of the time but I recently found such strings in non-error lines which I have to keep skipping. – Capt. Crunch May 02 '16 at 03:10
  • @AmosShapira That _may_ be the wrong approach to this. But let's see if anyone has a better idea. – ewwhite May 02 '16 at 03:11

0 Answers0