public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] less and colourisation
@ 2006-11-24  1:22 W.Kenworthy
  2006-11-24 18:04 ` Willie Wong
  0 siblings, 1 reply; 7+ messages in thread
From: W.Kenworthy @ 2006-11-24  1:22 UTC (permalink / raw
  To: gentoo-user List

I recently had cause to use "less" from a real console, not an xterm and
found that it really does colourise text.  It has never done this in an
xterm - how do I turn it on?  "man" isnt being very helpful here :(

BillK

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] less and colourisation
  2006-11-24  1:22 [gentoo-user] less and colourisation W.Kenworthy
@ 2006-11-24 18:04 ` Willie Wong
  2006-11-25  2:06   ` Thomas Rösner
  0 siblings, 1 reply; 7+ messages in thread
From: Willie Wong @ 2006-11-24 18:04 UTC (permalink / raw
  To: gentoo-user

On Fri, Nov 24, 2006 at 09:22:24AM +0800, Penguin Lover W.Kenworthy squawked:
> I recently had cause to use "less" from a real console, not an xterm and
> found that it really does colourise text.  It has never done this in an
> xterm - how do I turn it on?  "man" isnt being very helpful here :(
> 
> BillK

My best guess is the -R option:

      -R or --RAW-CONTROL-CHARS
              Like -r, but only ANSI "color" escape sequences are output
              in  "raw" form.  Unlike -r, the screen appearance is main-
              tained correctly  in  most  cases.   ANSI  "color"  escape
              sequences are sequences of the form:

                   ESC [ ... m

              where  the "..." is zero or more color specification char-
              acters For the purpose of keeping track of screen  appear-
              ance,  ANSI color escape sequences are assumed to not move
              the cursor.  You can make less think that characters 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.  And you
              can make less think that characters other than  the  stan-
              dard  ones may appear between the ESC and the m by setting
              the environment variable LESSANSIMIDCHARS to the  list  of
              characters which can appear.

HTH, 

W
-- 
(04:01:59) W: yep
(04:02:02) W: I love linux
(04:02:15) NJYWT: I love penguins
Sortir en Pantoufles: up 91 days, 11:36
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] less and colourisation
  2006-11-24 18:04 ` Willie Wong
@ 2006-11-25  2:06   ` Thomas Rösner
  2006-11-25 14:30     ` Willie Wong
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Rösner @ 2006-11-25  2:06 UTC (permalink / raw
  To: gentoo-user

Willie Wong wrote:
> On Fri, Nov 24, 2006 at 09:22:24AM +0800, Penguin Lover W.Kenworthy squawked:
>   
>> I recently had cause to use "less" from a real console, not an xterm and
>> found that it really does colourise text.  It has never done this in an
>> xterm - how do I turn it on?  "man" isnt being very helpful here :(
>>
>> BillK
>>     
>
> My best guess is the -R option:
>   

This is for programs having color output you want to pipe to less, not 
less showing a syntax highlighted file. This is done by the gentoo less 
filter that automagically unzips README.gz files when viewing them with 
less, fx. Does ls --color=auto produce colors in your xterm? Is your 
TERM envvar set to xterm (xterm should do this)? Do you have compared 
the current /etc/skel files to your user's home; when you create a new 
user with those files in his home, does xterm/less work for this account 
as intended?

Regards,
    T.
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] less and colourisation
  2006-11-25  2:06   ` Thomas Rösner
@ 2006-11-25 14:30     ` Willie Wong
  2006-11-25 19:18       ` Benno Schulenberg
  0 siblings, 1 reply; 7+ messages in thread
From: Willie Wong @ 2006-11-25 14:30 UTC (permalink / raw
  To: gentoo-user

On Sat, Nov 25, 2006 at 03:06:04AM +0100, Penguin Lover Thomas R?sner squawked:
> This is for programs having color output you want to pipe to less, not 
> less showing a syntax highlighted file. This is done by the gentoo less 
> filter that automagically unzips README.gz files when viewing them with 
> less, fx. Does ls --color=auto produce colors in your xterm? Is your 
> TERM envvar set to xterm (xterm should do this)? Do you have compared 
> the current /etc/skel files to your user's home; when you create a new 
> user with those files in his home, does xterm/less work for this account 
> as intended?

Oh jeez, I completely misunderstood the original post (not to mention
that I didn't realize the colourisation is a gentoo specific filter).
I just took a look at the filter program 'lesspipe.sh', and boy is it
nice! Even extracts mp3info/ogginfo (not that I'd have thought about
running less against mp3 or ogg-vorbis files before)!

But I don't think the TERM envvar is the issue here (OP should check it 
in any case). On my rxvt term, I run 
  TERM=<insertsomething> less <somesrcfile>
if I set the TERM to something that doesn't support color (dumb, or
some nonsense term), less (/usr/bin/less, not the lesspipe.sh) would
complain that it is not compatible with the -R option (which should be
set for all users in /etc/env.d/70less anyway), yet at the same time,
it would still send all the ANSI color codes produced by lesspipe.sh
as raw to the terminal, and the output still displays as colored. 

Just checking, in the xterm that doesn't work, what does the following
envvars show?

LESS   (should be -R -M --shift 5 by default)
LESSOPEN   (|lesspipe.sh %s)
LESSCOLOR  (should be empty by default)
LESSCOLORIZER  (ditto)

HTH, 

W
-- 
A grenade thrown into a kitchen in France would result in Linoleum Blownapart.
Sortir en Pantoufles: up 92 days,  7:43
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] less and colourisation
  2006-11-25 14:30     ` Willie Wong
@ 2006-11-25 19:18       ` Benno Schulenberg
  2006-11-26  2:08         ` Willie Wong
  0 siblings, 1 reply; 7+ messages in thread
From: Benno Schulenberg @ 2006-11-25 19:18 UTC (permalink / raw
  To: gentoo-user

Willie Wong wrote:
> LESS   (should be -R -M --shift 5 by default)

When doing

  export LESS="-R -M --shift 5"

a C-file viewed with 'less' is coloured.  But when doing

  export LESS="-RM --shift 5"

not.  What is being tripped up where here?

Benno
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] less and colourisation
  2006-11-25 19:18       ` Benno Schulenberg
@ 2006-11-26  2:08         ` Willie Wong
  2006-11-26 23:48           ` Benno Schulenberg
  0 siblings, 1 reply; 7+ messages in thread
From: Willie Wong @ 2006-11-26  2:08 UTC (permalink / raw
  To: gentoo-user

On Sat, Nov 25, 2006 at 08:18:27PM +0100, Penguin Lover Benno Schulenberg squawked:
> Willie Wong wrote:
> > LESS   (should be -R -M --shift 5 by default)
> 
> When doing
> 
>   export LESS="-R -M --shift 5"
> 
> a C-file viewed with 'less' is coloured.  But when doing
> 
>   export LESS="-RM --shift 5"
> 
> not.  What is being tripped up where here?
> 
Interesting, that is probably because of the following snip from
lesspipe.sh (the gentoo less filter)

     # Only colorize if we know less will handle raw codes
             for opt in ${LESS} ; do
                     if [[ ${opt} == "-r" || ${opt} == "-R" ]] ; then
                             ${LESSCOLORIZER} "$1"
                             break
                     fi
             done

I would probably consider that a bug worth filing on b.g.o. That
snipplet assumes that options would be specified 1 per dash with no
ganging, which does not fit in the old unix-style paradigm; but it
also completely ignores the gnu-style options given in the man page
(--raw-control-chars and --RAW-CONTROL-CHARS for -r and -R
respectively)

W
-- 
You should approach relationships like chess. And preferably as Deep Blue plays
it, or at least as Kasparov.
Sortir en Pantoufles: up 92 days, 19:33
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-user] less and colourisation
  2006-11-26  2:08         ` Willie Wong
@ 2006-11-26 23:48           ` Benno Schulenberg
  0 siblings, 0 replies; 7+ messages in thread
From: Benno Schulenberg @ 2006-11-26 23:48 UTC (permalink / raw
  To: gentoo-user

Willie Wong wrote:
>      # Only colorize if we know less will handle raw codes
>              for opt in ${LESS} ; do
>                      if [[ ${opt} == "-r" || ${opt} == "-R" ]] ;
> [...]
>
> I would probably consider that a bug worth filing on b.g.o.

Done, https://bugs.gentoo.org/show_bug.cgi?id=156362

Benno
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-11-26 23:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-24  1:22 [gentoo-user] less and colourisation W.Kenworthy
2006-11-24 18:04 ` Willie Wong
2006-11-25  2:06   ` Thomas Rösner
2006-11-25 14:30     ` Willie Wong
2006-11-25 19:18       ` Benno Schulenberg
2006-11-26  2:08         ` Willie Wong
2006-11-26 23:48           ` Benno Schulenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox