Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
alias less to less -r so fancy color output of emerge works
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
SkiingYAC
n00b
n00b


Joined: 18 Apr 2002
Posts: 20

PostPosted: Thu Apr 25, 2002 7:53 pm    Post subject: alias less to less -r so fancy color output of emerge works Reply with quote

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
View user's profile Send private message
klieber
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 3657
Location: San Francisco, CA

PostPosted: Thu Apr 25, 2002 8:05 pm    Post subject: Re: alias less to less -r so fancy color output of emerge wo Reply with quote

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
View user's profile Send private message
phaze3k
n00b
n00b


Joined: 24 Apr 2002
Posts: 36

PostPosted: Thu Apr 25, 2002 8:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
SkiingYAC
n00b
n00b


Joined: 18 Apr 2002
Posts: 20

PostPosted: Thu Apr 25, 2002 8:46 pm    Post subject: I like the colors but they should play nice Reply with quote

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
View user's profile Send private message
stevil
n00b
n00b


Joined: 22 Apr 2002
Posts: 12
Location: Minneapolis, MN

PostPosted: Thu Apr 25, 2002 9:29 pm    Post subject: Reply with quote

why not use more?
Back to top
View user's profile Send private message
aj
n00b
n00b


Joined: 25 Apr 2002
Posts: 7

PostPosted: Fri Apr 26, 2002 2:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
IOOOOOI
n00b
n00b


Joined: 18 May 2002
Posts: 11
Location: Los Angeles

PostPosted: Sun May 19, 2002 9:52 am    Post subject: Re: alias less to less -r so fancy color output of emerge wo Reply with quote

'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
View user's profile Send private message
clacour
n00b
n00b


Joined: 19 Apr 2002
Posts: 59
Location: Dallas, Tx USA

PostPosted: Tue May 21, 2002 11:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
IOOOOOI
n00b
n00b


Joined: 18 May 2002
Posts: 11
Location: Los Angeles

PostPosted: Wed May 22, 2002 4:59 pm    Post subject: Reply with quote

Excellent
_________________
-- IOOOOOI
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum