| | |
Using color escape codes in less
![]() |
•
•
Join Date: Sep 2008
Posts: 2
Reputation:
Solved Threads: 0
Hi all,
Please forgive me if you saw this post in other forums as well. I just do not seem to get any answer....
A. My Environment
==============
I am using RedHat Linux, version 2.6.18-53.el5.
When I type less --version I get:
less 394
Copyright © 1984-2005 Mark Nudelman
...
My terminal is configured as Xterm, using ANSI colors and indeed, typing
ls --color=yes produces a colored list.
B. Background
===========
I am using a small pearl script that colors lines of text according to predefined key words.
This is a very nice utility. When I redirect tail -f output to it, it produces nice color logs of my server, with words such as "Exception" or "Error" conveniently colored.
Recently I wanted to try a more ambitious use of this script: To use it together with less command.
Anyone can understand, that less +F is better than tail -f, as one can press CTRL+C at any given time when viewing a file online, and scroll or search within it effortlessly, without ever returning to the shell prompt.
Which leads me to:
C. The Problem
===========
1. I can not get less to show color.
Even typing "ls --color=yes > test.txt"
and then less -r text.txt or less -R text.txt NEVER displays the content in color. The output is actually the same as doing a "ls --color=no"
2. I read a bit about less input preprocessor the related Environment Variables in UNIX man pages : less ().
3.But, I can not figure out how I can turn less to use colors on a regular basis, How I can make less to "relay" all its output through my color pearl script, and mostly - Is it possible at all?
Any help would be highly appreciated.
Attached are my colorlogs.pl and colorlogs.conf files, to complement this post.
Thank you in advance.
Please forgive me if you saw this post in other forums as well. I just do not seem to get any answer....
A. My Environment
==============
I am using RedHat Linux, version 2.6.18-53.el5.
When I type less --version I get:
less 394
Copyright © 1984-2005 Mark Nudelman
...
My terminal is configured as Xterm, using ANSI colors and indeed, typing
ls --color=yes produces a colored list.
B. Background
===========
I am using a small pearl script that colors lines of text according to predefined key words.
This is a very nice utility. When I redirect tail -f output to it, it produces nice color logs of my server, with words such as "Exception" or "Error" conveniently colored.
Recently I wanted to try a more ambitious use of this script: To use it together with less command.
Anyone can understand, that less +F is better than tail -f, as one can press CTRL+C at any given time when viewing a file online, and scroll or search within it effortlessly, without ever returning to the shell prompt.
Which leads me to:
C. The Problem
===========
1. I can not get less to show color.
Even typing "ls --color=yes > test.txt"
and then less -r text.txt or less -R text.txt NEVER displays the content in color. The output is actually the same as doing a "ls --color=no"
2. I read a bit about less input preprocessor the related Environment Variables in UNIX man pages : less ().
3.But, I can not figure out how I can turn less to use colors on a regular basis, How I can make less to "relay" all its output through my color pearl script, and mostly - Is it possible at all?
Any help would be highly appreciated.
Attached are my colorlogs.pl and colorlogs.conf files, to complement this post.
Thank you in advance.
![]() |
Similar Threads
- C serial com port terminal program (C)
- Open In New Window Php (PHP)
- Use of Color in C++ (C++)
- login screen config (Window and Desktop Managers)
Other Threads in the *nix Software Forum
- Previous Thread: DSL-N loaded and found my modem, need Firefox now to test link.
- Next Thread: How to extract .rpm files from .bin file
| Thread Tools | Search this Thread |





