LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo
User Name
Password
Gentoo This forum is for the discussion of Gentoo Linux.

Notices

Reply
 
Search this Thread
Old 07-18-2012, 05:59 AM   #1
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 80
Man pages with colors under Gentoo


Code:
man() {
    LESS_TERMCAP_mb=$(printf "\e[1;31m") \
    LESS_TERMCAP_md=$(printf "\e[1;31m") \
    LESS_TERMCAP_me=$(printf "\e[0m") \
    LESS_TERMCAP_se=$(printf "\e[0m") \
    LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
    LESS_TERMCAP_ue=$(printf "\e[0m") \
    LESS_TERMCAP_us=$(printf "\e[1;32m") \
      command man "$@"
}
I've been able to append that to my .bashrc in other distros, and it causes the man pages to have colors. In the picture below shows it working in Fedora. It works in both zsh and bash. I have not tested it in any others. It does not work in Gentoo under zsh or bash. How come? How can it be made to work under Gentoo?

I found it on the Arch Wiki https://wiki.archlinux.org/index.php...ing_.27less.27

I talked to the people in #bash on freenode, and they said it could be implemented better. I've tried it there way, and the Arch wiki's way. Neither work under Gentoo.

Last edited by fakie_flip; 07-18-2012 at 06:00 AM. Reason: formatting of code
 
Old 07-18-2012, 08:48 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,630
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Have you set 'less' as your pager in /etc/man_db.conf ? If it doesn't work with less, have you tried it with 'more' instead?
 
Old 07-18-2012, 12:37 PM   #3
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Original Poster
Rep: Reputation: 80
echo $PAGER shows less -R

man less

Code:
       -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.


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

                   ESC [ ... m

              where  the  "..."  is  zero  or  more color specification characters For the purpose of keeping track of
              screen appearance, 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 standard ones may appear between the ESC and the m by
              setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear.
Why is this enabled? Would it be harmful if I removed it? The Gentoo Terminal, emerge, etc has a lot of colors, not sure why they would do this.

Last edited by fakie_flip; 07-18-2012 at 12:43 PM.
 
Old 07-18-2012, 01:10 PM   #4
fogpipe
Member
 
Registered: Mar 2011
Distribution: Slackware 64 Current
Posts: 329

Rep: Reputation: 77
This is what i have in my .bashrc for the same purpose:
Code:
export LESS="-R"
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
and it works. Note the lack of curly brackets or paras and the fact that the above is not enclosed in a function of any kind.

EDIT: and by "it works" what i mean is that it gives you red and green text in man pages.

Last edited by fogpipe; 07-18-2012 at 01:12 PM.
 
Old 07-19-2012, 06:07 AM   #5
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Original Poster
Rep: Reputation: 80
I just installed most. It's in the repositories, can be emerge'd. It defaults to using the same colors. All I needed to do after that was get the vim like jk keys to scroll up and down by creating a .mostrc, two lines. Also, put in .bashrc and .zshrc export PAGER="most"

bullshark@beastlinux ~ % cat .mostrc
setkey "up" "k"
setkey "down" "j"
bullshark@beastlinux ~ %
 
Old 07-19-2012, 05:11 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,900

Rep: Reputation: 774Reputation: 774Reputation: 774Reputation: 774Reputation: 774Reputation: 774Reputation: 774
Here is an article on the subject; I have to say that I tried it (SUSE) and was severely underwhelemed. Occasionally a single word gets coloured, but the large scale colouring that is seen in the article doesn't happen for me (although I can't say that I was that bothered...it just seemed like a cool trick).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use man pages babu198649 Linux - Newbie 15 10-12-2007 09:17 AM
man pages with colors in xterm milod Linux - Software 4 03-30-2006 11:34 PM
Man page colors daelomin Linux - Newbie 5 03-16-2005 07:25 AM
Man page colors daelomin Red Hat 1 03-14-2005 11:45 AM
Man pages twantrd Solaris / OpenSolaris 5 08-16-2004 03:15 AM


All times are GMT -5. The time now is 05:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration