You are not logged in.

#1 2018-03-19 20:03:19

Condor
Member
Registered: 2017-12-01
Posts: 54

[SOLVED] Colored man pages from Xfce whisker menu

From the Xfce whisker menu, one can very quickly open man pages by typing

#curl

in the search field, which is handy. This opens the standard terminal and launches man for the requested program. Actually, the command

exo-open --launch TerminalEmulator man %s

is executed.

In an alias file, which is sourced from ~/.bashrc, the call to “man“ is redefined and sets some coloring. For me, that improves readability and structure of the man pages.

## Colored man pages ##
man() {
    LESS_TERMCAP_mb=$'\e[1,31m' \
    LESS_TERMCAP_md=$'\e[1;31m' \
    LESS_TERMCAP_me=$'\e[0m' \
    LESS_TERMCAP_se=$'\e[0m' \
    LESS_TERMCAP_so=$'\e[0;37;102m' \
    LESS_TERMCAP_ue=$'\e[0m' \
    LESS_TERMCAP_us=$'\e[4;32m' \
    command man "$@"
}

When launching from the whisker menu, of course neither .bashrc nor my alias file are sourced.  I tried fiddling with the exo-open command to run bash -c and call man from there, but to no avail.

How to get the colored man pages when opened through the whisker menu's search function?

Last edited by Condor (2018-03-20 13:22:19)

Offline

#2 2018-03-19 20:10:13

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Colored man pages from Xfce whisker menu

You can export those in your .profile/.bash_profile (provided it is read on login):

export LESS_TERMCAP_mb=$'\E[01;31m
etc...

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-03-19 20:20:27

progandy
Member
Registered: 2012-05-17
Posts: 5,193

Re: [SOLVED] Colored man pages from Xfce whisker menu

I think if you create your function as an executable shell script called "man" in $PATH, exo-open should locate and run it. This would be useful if you want less to be only colored when displaying manpages and not for other data.
It may be cleaner to globally set MANPAGER to a custom script and use it to set the options for less instead of wrapping man.

Edit: In most cases, you won't care about the modified coloring of "less -R" output, so simply setting it in your ~/.(bash_)profile should work perfectly fine.

Last edited by progandy (2018-03-19 20:36:01)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#4 2018-03-20 13:22:00

Condor
Member
Registered: 2017-12-01
Posts: 54

Re: [SOLVED] Colored man pages from Xfce whisker menu

Oh my, I did not know where this seemingly simple answer would take me. Down then rabbit hole of shell profile, bashrc and more :-)

Anyway, I solved the issue. Thank you for your help!


For completeness, my findings for future reference:
The idea of replacing the search function of the whisker menu by a custom script seemed simple enough, but solves the problem for one task only. Also, I'm quite fond of using “sudoedit“ and could not get it around to using nano instead of vim. Setting VISUAL and/or EDITOR environment variables in .bash_profile did not help.

So, with the lead of .profile/.bash_profile provided it is read on login, I undertook some research. Over at askubuntu.com there was the thread Why ~/.bash_profile is not getting sourced when opening a terminal?, with a nice summary of what is sourced when. Also, Greg's wiki has a story about dot files in bash.

The crucial point is: When logging in through a graphical session manager (lightdm in my case), none of the bash profile/rc/login files are processed – with the exception of ~/.profile (and even that one seems to differ between session managers).

I've put the TERMCAP stuff in ~/.profile, and it works.

Offline

Board footer

Powered by FluxBB