[clug] Coloured manpages
Scott Ferguson
scott.ferguson.clug at gmail.com
Mon Feb 17 19:13:02 MST 2014
On 18/02/14 12:30, Ivan Lazar Miljenovic wrote:
> On 18 February 2014 12:04, Hal Ashburner <hal at ashburner.info> wrote:
>> Getting coloured output from manpages brought me some joy today! Hopefully
>> someone or other of you manages a smile. This is the kind of thing that
>> often get past me for years(!)
>>
>> http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/
>>
>> which can be wrapped like so:
>>
>> man() {
>> env \
>> LESS_TERMCAP_mb=$(printf "\e[1;31m") \
>> LESS_TERMCAP_md=$(printf "\e[1;38;5;74m") \
>> LESS_TERMCAP_me=$(printf "\e[0m") \
>> LESS_TERMCAP_se=$(printf "\e[0m") \
>> LESS_TERMCAP_so=$(printf "\e[1;38;5;246m") \
>> LESS_TERMCAP_ue=$(printf "\e[0m") \
>> LESS_TERMCAP_us=$(printf "\e[04;38;5;146m") \
>> man "$@"
>> }
>>
>> if that floats your boat.
Nice.
Don't forget to follow it with:-
$ . ~/.bashrc
I use:-
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
man "$@"
}
See:- http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
>
> I found this and tried using it on a freshly installed Fedora 20 using
> Gnome 3, and for some reason the Gnome terminal wouldn't display them
> (except for possibly the bottom bar being a different colour). It
> worked in xterm though...
>
> So I went back to just using most for my pager for man, even though it
> has some weird aspects to it (when searching, a coloured word counts
> as two search results :s).
>
>>
>> (also in my shellrc are settings for ls & grep which along with tweaks to
>> .hgrc and compiling with clang make me happy)
>>
>> # Enable directory colours
>> [[ $OSTYPE == "linux" ]] && eval `dircolors`
>> [[ $OSTYPE == "linux" ]] && alias ls="ls --color=auto -F"
>> alias grep="grep --color=auto"
Default Debian .bashrc
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval
"$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
>>
>> Hope you're having fun.
>> --
>> linux mailing list
>> linux at lists.samba.org
>> https://lists.samba.org/mailman/listinfo/linux
>
>
>
Kind regards
More information about the linux
mailing list