Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-25-2008, 10:28 PM
|
#1
|
Member
Registered: Aug 2008
Location: austin, tx
Distribution: Slackware64
Posts: 35
Rep:
|
color support for less or most
Hello. Does anyone know how to keep colored text when viewing files through less or most? Thanks.
|
|
|
08-25-2008, 10:41 PM
|
#2
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
The terminal emulator must support, and be set for, color.
What terminal type are you using ?
echo $TERM
|
|
|
08-26-2008, 10:22 AM
|
#3
|
Member
Registered: Aug 2008
Location: austin, tx
Distribution: Slackware64
Posts: 35
Original Poster
Rep:
|
echo $TERM
linux
I did say "keep" color, which implies that my bash terminal uses color except with the less program.
|
|
|
08-26-2008, 11:47 AM
|
#4
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
I see. There is no shortage of poorly worded questions in the forums, and it is not always easy to pull the relavant facts from sloppy language.
Less and more do not have syntax highlighting, so the best color you will get with them is two color (foreground/background) plus any standard attributes such as bold, underline, blink, etc.
|
|
|
08-26-2008, 02:18 PM
|
#5
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Try the -R option to less.
|
|
|
08-26-2008, 02:22 PM
|
#6
|
Senior Member
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094
Rep:
|
Depending on exactly what you want to do you may find the -r option on less useful. Try these commands
Code:
$ (echo -e "\E[1;34m";ls) | less
$ (echo -e "\E[1;34m";ls) | less -r
and note how in the first one the first line of what less displays is "ESC[1;34m" but in the second command that line is missing and all the text is blue. I used this recently where I wanted to have some coloured output in something that would be displayed by less. E.g. this is a very crude and convoluted example of colouring the output of ls when it's display with less
Code:
$ foo=`for i in *;do if test -d "$i";then echo "\E[1;34m" ;fi; ls -lhd "$i";echo "\E[0m\n"; done` && echo -e $foo | less -r
|
|
|
08-29-2008, 02:59 AM
|
#7
|
Member
Registered: Aug 2008
Location: austin, tx
Distribution: Slackware64
Posts: 35
Original Poster
Rep:
|
Quote:
Originally Posted by Mr. C.
I see. There is no shortage of poorly worded questions in the forums, and it is not always easy to pull the relavant facts from sloppy language.
|
"Relevant" is misspelled. And thanks to arizonagroovejet.
Last edited by leftty; 08-29-2008 at 03:02 AM.
|
|
|
08-29-2008, 03:22 AM
|
#8
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
And so is leftty. Find more interesting things to say.
|
|
|
10-24-2014, 02:02 PM
|
#9
|
LQ Newbie
Registered: Oct 2014
Posts: 1
Rep:
|
Try this
ls -R /bin --color=always | less -r
ls -R /bin /etc | sort | uniq | grep --color=always sh | less -r
the keys are: - -r option for less.
- and --color=always option for the other one.
|
|
|
All times are GMT -5. The time now is 06:38 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|