-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mick said the following on 2007-04-05 19:07:
| ...
| Hmm, neither less not cat give me color output.  Passing --color=y to
either
| tells me things like:
| ==============================
| There is no color=y option ("less --help" for help)
| ==============================
|
| I also tried --color but it's all still shown in black & white.  How
do you
| pipe a file and get it to show in color?  Am I missing something in
| my .bashrc or elsewhere?

To make less interpret color escape sequences, you need the -R option.
export LESS=-R in your shell startup script and you-ll have it as
default. Generally, you don't want to use less -r, which allows
arbitrary control characters through to affect the terminal (which tend
to create major garbage).

Color is added via ANSI escape sequences, which don't work in all
displays/terminals/consoles, but as an example: grep is smart enough to
detect this and won't use color (even when specified) if you're sending
the output via a pipeline. Otherwise, if you piped the output, eg to
less, the ANSI escape sequences would send garbage to the screen.

~ If, on the other hand, that's really what you want to do (without the
garbage), there's a workaround:

use the --color=always to force it through and call less with the -R
flag (which prints ALL RAW control characters). That way, the color
codes will escape correctly and you'll page through screens of text with
your matched patterns in full color:

grep --color=always "regexp" the_file_you_want_to_wade_through | less -R

That should do the trick :)

//Regards Tony

PS. Have a nice Easter everyone!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)

iD8DBQFGFUjWJDzv6DN+QUkRArevAKDoe0VND3TXj0o0kV3KkrD7cwPmBgCfUF27
VgMOQFi+i5rwL2p0rpljZ70=
=w/na
-----END PGP SIGNATURE-----
--
gentoo-user@gentoo.org mailing list

Reply via email to