View previous topic :: View next topic |
Author |
Message |
SkiingYAC n00b
Joined: 18 Apr 2002 Posts: 20
|
Posted: Thu Apr 25, 2002 7:53 pm Post subject: alias less to less -r so fancy color output of emerge works |
|
|
I suggest that less be aliased to less -r by default so that you can do
Code: | emerge search gnome | less | and you don't get this:
Quote: | ESC[33;01m/usrESC[0;0m
ESC[33;01m/usr/shareESC[0;0m
ESC[33;01m/usr/share/docESC[0;0m
|
|
|
Back to top |
|
|
klieber Bodhisattva
Joined: 17 Apr 2002 Posts: 3657 Location: San Francisco, CA
|
Posted: Thu Apr 25, 2002 8:05 pm Post subject: Re: alias less to less -r so fancy color output of emerge wo |
|
|
SkiingYAC wrote: | I suggest that less be aliased to less -r by default |
Yes, but looking at 'man less', that means we would run into the following:
Quote: | -r or --raw-control-chars
Causes "raw" control characters to be displayed.
The default is to display control characters using
the caret notation; for example, a control-A (octal
001) is displayed as "^A". Warning: when the -r
option is used, less cannot keep track of the
actual appearance of the screen (since this depends
on how the screen responds to each type of control
character). Thus, various display problems may
result, such as long lines being split in the wrong
place.
|
So you're fixing one problem, but possibly introducing a great deal of additional problems. Not sure the net result is positive.
--kurt _________________ The problem with political jokes is that they get elected |
|
Back to top |
|
|
phaze3k n00b
Joined: 24 Apr 2002 Posts: 36
|
Posted: Thu Apr 25, 2002 8:10 pm Post subject: |
|
|
Personally I'd prefer getting rid of the colours altogether - they're unnecessary, and create problems such as this. It's really not the fault of less that it can't work out where to split the line - it's pretty much impossible to do.
If colours are to be kept, then I'd recommend less being aliased as suggested, a bit of weird line-wrapping is certainly better than the colour-codes everywhere. |
|
Back to top |
|
|
SkiingYAC n00b
Joined: 18 Apr 2002 Posts: 20
|
Posted: Thu Apr 25, 2002 8:46 pm Post subject: I like the colors but they should play nice |
|
|
Alright if less will complain then thats fine, but I agree with phase3k that color codes are worse than a few random line breaks. I realize this is a generalization, but most people never pipe anything through less that isn't more or less plain text.
Maybe an option should be added to the color-outputting commands to pipe them through something or add scrolling so that I don't have to scroll on my terminal to see everything (or the stuff in the beginning gets chopped off). I don't know if this is possible, but could they maybe detect that they are being piped to something and drop the colors?
Or create a patched version of less and call it cless or colorless or something so that it is smarter than regular less for the color codes.
Or even simpler, alias cless to less -r, and document it as the way to handle long color output. |
|
Back to top |
|
|
stevil n00b
Joined: 22 Apr 2002 Posts: 12 Location: Minneapolis, MN
|
Posted: Thu Apr 25, 2002 9:29 pm Post subject: |
|
|
why not use more? |
|
Back to top |
|
|
aj n00b
Joined: 25 Apr 2002 Posts: 7
|
Posted: Fri Apr 26, 2002 2:33 pm Post subject: |
|
|
You might try -R:
Like -r, but tries to keep track of the screen
appearance where possible. This works only if the
input consists of normal text and possibly some
ANSI "color" escape sequences, which are sequences
of the form:
ESC [ ... m
where the "..." is zero or more characters other
than "m". For the purpose of keeping track of
screen appearance, all control characters and all
ANSI color escape sequences are assumed to not move
the cursor. You can make less think that charac
ters other than "m" can end ANSI color escape
sequences by setting the environment variable
LESSANSIENDCHARS to the list of characters which
can end a color escape sequence.
% cat /var/log/kern.log | colorize | less -r
Works well, tho. |
|
Back to top |
|
|
IOOOOOI n00b
Joined: 18 May 2002 Posts: 11 Location: Los Angeles
|
Posted: Sun May 19, 2002 9:52 am Post subject: Re: alias less to less -r so fancy color output of emerge wo |
|
|
'less -r' (or -R) works ok for viewing, but if you ever want to redirect output you still have to deal with the ESC sequences. I agree that colors are more of a hassle than help in this instance. _________________ -- IOOOOOI |
|
Back to top |
|
|
clacour n00b
Joined: 19 Apr 2002 Posts: 59 Location: Dallas, Tx USA
|
Posted: Tue May 21, 2002 11:31 pm Post subject: |
|
|
I had similar problems a while back (trying to parse the output of "emerge search" with a script) and somebody told me how to turn on the "NOCOLOR" variable:
Edit /etc/make.conf
Somewhere in it (I used the bottom) put:
NOCOLOR=true
I believe this applies to all activities of emerge, not just emerge search. |
|
Back to top |
|
|
IOOOOOI n00b
Joined: 18 May 2002 Posts: 11 Location: Los Angeles
|
Posted: Wed May 22, 2002 4:59 pm Post subject: |
|
|
Excellent _________________ -- IOOOOOI |
|
Back to top |
|
|
|