View previous topic :: View next topic |
Author |
Message |
qnx l33t
Joined: 25 Jun 2002 Posts: 638 Location: Göteborg, Sweden
|
Posted: Sat Dec 14, 2002 10:14 pm Post subject: Display color output in less |
|
|
Hi! When I run
the result I get is less readable... Something like:
Code: | ESC[0;01mUsage:
ESC[36;01mqpkgESC[0;0m [ESC[0;01moptionsESC[0;0m] [ESC[33;01mpkgnameESC[
0;0m] [ESC[34;01m-gESC[33;01m groupESC[0;0m] [ESC[34;01m-fESC[33;01m <file>ESC[0
;0m|ESC[34;01m-fpESC[33;01m <patern>ESC[0;0m]
ESC[36;01mqpkgESC[0;0m ESC[34;01m--dupsESC[0;0m [ESC[34;01m--slotESC[0;0
m]
ESC[36;01mqpkgESC[0;0m ESC[34;01m--helpESC[0;0m
|
What can I do to display colors in less?? Or should I use another pager??
Cheers!
P.S. Of course, in this case I can just run qpkg with -nc atribut (no color). But I have this problem with other commands that do not support no-color-mode. Also, I hate to use more. _________________ Registred Linux user #191143!
Abit NF7-S rev. 2.00 (BIOS v. 2.7)
AMD AthlonXP 2500+ (Barton)
PATA Seagate ST3120022A
SATA Seagate ST3200822AS & Silicon Image 3112 chipset
Gentoo Linux |
|
Back to top |
|
|
Pigeon Guru
Joined: 21 Jun 2002 Posts: 307
|
Posted: Sat Dec 14, 2002 11:09 pm Post subject: |
|
|
Code: | qpkg --help|less -R |
|
|
Back to top |
|
|
qnx l33t
Joined: 25 Jun 2002 Posts: 638 Location: Göteborg, Sweden
|
Posted: Sat Dec 14, 2002 11:10 pm Post subject: |
|
|
Thanks man! _________________ Registred Linux user #191143!
Abit NF7-S rev. 2.00 (BIOS v. 2.7)
AMD AthlonXP 2500+ (Barton)
PATA Seagate ST3120022A
SATA Seagate ST3200822AS & Silicon Image 3112 chipset
Gentoo Linux |
|
Back to top |
|
|
carambola5 Apprentice
Joined: 10 Jul 2002 Posts: 214
|
Posted: Sun Dec 15, 2002 12:35 am Post subject: |
|
|
fewer keystrokes |
|
Back to top |
|
|
joycea Apprentice
Joined: 23 Jul 2002 Posts: 191 Location: Kingston, Canada
|
Posted: Sun Dec 15, 2002 2:38 am Post subject: |
|
|
To make it permanent you can alias less in your .bashrc file such as,
Code: |
alias less="less -r"
|
or you can set the environment variable LESS, such as,
Both of these will make the color option rather automatic. |
|
Back to top |
|
|
qnx l33t
Joined: 25 Jun 2002 Posts: 638 Location: Göteborg, Sweden
|
Posted: Sun Dec 15, 2002 10:00 am Post subject: |
|
|
Yes, it's a good idea to alias less with -r. Thanks! _________________ Registred Linux user #191143!
Abit NF7-S rev. 2.00 (BIOS v. 2.7)
AMD AthlonXP 2500+ (Barton)
PATA Seagate ST3120022A
SATA Seagate ST3200822AS & Silicon Image 3112 chipset
Gentoo Linux |
|
Back to top |
|
|
foxcub Tux's lil' helper
Joined: 25 Jun 2002 Posts: 131 Location: North Carolina
|
Posted: Mon May 19, 2003 6:44 pm Post subject: |
|
|
Here is a follow up question. Why is "emerge -s phoenix" (or any other package) colorized, while "emerge -s phoenix | more" is not? And how can I colorize the later one?
Thanks. |
|
Back to top |
|
|
sekh n00b
Joined: 20 Dec 2002 Posts: 55
|
Posted: Tue May 20, 2003 1:49 pm Post subject: |
|
|
sorry to bring back this thread from the dead
But does anyone know the answer to the question in the above post? i was wondering this myself? |
|
Back to top |
|
|
joycea Apprentice
Joined: 23 Jul 2002 Posts: 191 Location: Kingston, Canada
|
Posted: Tue May 20, 2003 4:44 pm Post subject: |
|
|
I don't think either less or more are capable of displaying the colours, only stripping out the control characters. I don't know if there is going to be a simple solution to this problem, it may have to do with how less and more have to keep redrawing the display that they are discarded. |
|
Back to top |
|
|
PowerFactor Veteran
Joined: 30 Jan 2003 Posts: 1693 Location: out of it
|
Posted: Tue May 20, 2003 7:27 pm Post subject: |
|
|
foxcub wrote: | Here is a follow up question. Why is "emerge -s phoenix" (or any other package) colorized, while "emerge -s phoenix | more" is not? | I think it is something in emerge that checks if it's output is the terminal or a pipe I say this because qpkg still colorizes the output when piped or redirected, unless you specify the --nocolor option. I don't know if there is any way to change this without modifying emerge, nothing listed in the man page.
joycea, did you not read any of the previous posts? Both less and more can display color. |
|
Back to top |
|
|
foxcub Tux's lil' helper
Joined: 25 Jun 2002 Posts: 131 Location: North Carolina
|
Posted: Tue May 20, 2003 11:17 pm Post subject: |
|
|
Is this worth submitting a bug report (to bugzilla)? |
|
Back to top |
|
|
sekh n00b
Joined: 20 Dec 2002 Posts: 55
|
Posted: Wed May 21, 2003 12:12 pm Post subject: |
|
|
joycea: less is quite capable of displaying colors.... try for instance
Code: | qpkg --help | less -R |
or
Code: | ls -l --color | less -R |
should work
what powerfactor suggest about it checking what the output is sounds like a probable reason to me howver it would be nice to be able to do an
Code: | emerge -up system | less -R |
when the update list is REALLY long :p |
|
Back to top |
|
|
BigBaaadBob Guru
Joined: 19 Apr 2003 Posts: 342 Location: Swampscott, MA USA
|
Posted: Wed May 21, 2003 11:11 pm Post subject: |
|
|
I was going to post a bug report about this.
What typcally happens is that programs check to see whether the stdout is a tty, and if it isn't they (by default) turn off all fancy stuff like color. This still allows you to use color if you want, by specifying explicit options. The theory is that if the stdout isn't a tty then it is probably a pipeline where you want to deal with the raw data. An example would be: where you don't want all the colorizing stuff to end up in the character count.
Qpkg also misbehaves when working into a pipeline like this: Code: | spooky root # qpkg -l -nc emacs | less
/usr/bin/qpkg: line 478: 9635 Broken pipe cat
/usr/bin/qpkg: line 478: 9632 Exit 141 if [ ! \( "${tcheck}" -o "${mcheck}" -o "${info}" -o "${list}" -o "${query}" -o ${verb} -gt 0 \) ]; then
sed -e "s:-r[0-9]\+$::" -e "s:-[0-9][^-]*$::" | sort -k2 | uniq -1;
else
if [ ! \( "${tcheck}" -o "${mcheck}" -o "${info}" -o "${list}" -o "${query}" -o ${verb} -lt 2 \) ]; then
sort -k2 | uniq -1;
else
cat;
fi;
fi
9634 Broken pipe | sed -e "s:^iii ${X}/${X}:${BR}\1/${CY}\2${STAR}${NO}:" -e "s:^uuu ${X}/${X}:${BR}\1/${YL}\2${NO}:" -e "s:^vvv \(.*\)$:${BL}\1${NO}:" -e "s:^obj ::;s:^sym ::;s:^dir ::"
/usr/bin/qpkg: line 478: 9641 Broken pipe sed -e "s:\(^obj \)\([^ ]*\)\(.*$\):\1${BR}\2${NO}:;
s:\(^sym \)\([^ ]*\)\( -> \)\([^ ]*\)\(.*$\):\1${CY}\2${NO}\3\4:;
s:\(^dir \)\([^ ]*\)\(.*$\):\1${YL}\2${NO}:"
/usr/bin/qpkg: line 478: 9640 Broken pipe cat $d/CONTENTS
s | What happened is I hit "q" in less.
As I said I was going to report it as a bug, but I wanted to take a crack at fixing it first. In my free time.... Riiiight... |
|
Back to top |
|
|
foxcub Tux's lil' helper
Joined: 25 Jun 2002 Posts: 131 Location: North Carolina
|
Posted: Thu May 22, 2003 12:09 am Post subject: |
|
|
So in other words, both qpkg and emerge need an explicit "--color" option that would force the output to include the control characters even if it's going into the pipe; and without it both programs should check whether they are outputting into a tty, and based on that include or exclude the control information? Just trying to make sure I understood you correctly. |
|
Back to top |
|
|
BigBaaadBob Guru
Joined: 19 Apr 2003 Posts: 342 Location: Swampscott, MA USA
|
Posted: Thu May 22, 2003 12:40 am Post subject: |
|
|
foxcub: Yup. I expressed it as deciding on the "default" option of color or nocolor based on whether or not stdout is a tty, but you said it just as well. |
|
Back to top |
|
|
_Vinz_ n00b
Joined: 22 Jan 2004 Posts: 20 Location: Vannes, France
|
Posted: Wed Feb 18, 2004 10:02 am Post subject: |
|
|
Hi,
I have been encountering the same problem. Is there any progress in that field before I post a bug report on Bugzilla to add a default --color option to emerge?
Vinz |
|
Back to top |
|
|
foxcub Tux's lil' helper
Joined: 25 Jun 2002 Posts: 131 Location: North Carolina
|
Posted: Thu Feb 19, 2004 12:24 am Post subject: |
|
|
Not that I know of, so I'd file a bug report since I don't think anybody else has bothered to look at this problem, though, to be frank I have no clue. |
|
Back to top |
|
|
_Vinz_ n00b
Joined: 22 Jan 2004 Posts: 20 Location: Vannes, France
|
Posted: Thu Feb 19, 2004 7:45 am Post subject: |
|
|
Yo foxcub,
Thanks for the reply. Looking on the database, I found these related problems :
bugs #1006 and #5714. They are more or less related to our problem.
Bug report filed in : https://bugs.gentoo.org/show_bug.cgi?id=42115
I'll let you know how it goes.
Vinz |
|
Back to top |
|
|
AVernon n00b
Joined: 06 Mar 2004 Posts: 3 Location: Atlanta, GA
|
|
Back to top |
|
|
devslashzero n00b
Joined: 28 Feb 2012 Posts: 1
|
Posted: Tue Feb 28, 2012 4:53 pm Post subject: Back from the dead |
|
|
Wow, 2004... Well, emerge still doesn't do this by default, so I spent a long while accepting monochrome paged output until I found this thread and poked around the manpages for less and emerge. In case it helps someone else, the following is a working combination of the two:
Code: | emerge --color y | less |
That is, less doesn't need -r or -R in this chain. The hint to emerge takes care of it. |
|
Back to top |
|
|
|