walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
587 stars 17 forks source link

How can I change man page colors? #170

Open BarbzYHOOL opened 6 months ago

BarbzYHOOL commented 6 months ago

Hello, I set moar as the default pager I had the same colors using LESS in the man pages

It's very dark and the worst is using the search tool and the result is highlighted but I see nothing, it's grey on grey

What can I do?

walles commented 6 months ago

Hello!

Please run the following commands and add their output to this issue:

Also, please post a screenshot of what moar looks like for you.

BarbzYHOOL commented 6 months ago
LESS=-FXMigR
-wrap -colors 16M
v1.18.4

image image In the last screenshot I looked for "palette"

walles commented 6 months ago

To verify that you actually did run env | grep '^LESS' | sort, could you post both the command line (env | grep '^LESS' | sort), its output and the prompt following it?

It looks like you have some LESS_xxx coloring variables set, and I want to verify that's the cause.

For example, here's what I get:

~/d/g/s/g/b/moar (master|✔) $ env | grep '^LESS' | sort
~/d/g/s/g/b/moar (master|✔) $
BarbzYHOOL commented 6 months ago
env | grep '^LESS' | sort                                                                                                                 00:18:32
LESS=-FXMigR

I'm not sure how LESS is related to MOAR tho

walles commented 6 months ago

For compatibility reasons, moar uses the formats declared in these environment variables if present:

But you do not have any of these set?

BarbzYHOOL commented 6 months ago

no, i checked with "echo $LESS_TERMCAP_md" etc

walles commented 6 months ago

If you run this, do you still get the same problem?

man moar | LESS_TERMCAP_md= LESS_TERMCAP_us= LESS_TERMCAP_so= moar

If this doesn't help I think the next step would be to improve moar --help output to explain where moar is getting its colors from.

BarbzYHOOL commented 6 months ago

Yes, it changes the result by highlighting the search result (the rest is not good looking) So hmmm to have good looking man pages, what do I do?

image

walles commented 6 months ago

I'd suggest you play around with LESS_TERMCAP_md, LESS_TERMCAP_us and LESS_TERMCAP_so and set colors that you like.

Also try the --style parameter, unsure how that affects man pages but you should try!

See #14 and #114 for what the LESS_TERMCAP_xx variables affect, and https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters for inspiration.

Try https://chat.openai.com/ and see if it can guide you for how to set this up nicely for your shell!

walles commented 6 months ago

I thought about this some more and I think two things should be improved in moar.

BarbzYHOOL commented 6 months ago

I don't understand the "--style" thing, without it asks for argument, and then I dunno what argument to type, I tried "style" or "api" nothing works

BarbzYHOOL commented 6 months ago

And to be fair, it doesn't work

 echo $LESS_TERMCAP_so                                                                                                                
\E[38;5;204m

I set it using fish shell with "set" but it does not change anything in the man page.

Also using "moar /etc/aliases" I can see the white highlight on search........ i don't get it

I even used these

set LESS_TERMCAP_mb '\E[01;31m'
set LESS_TERMCAP_md '\E[01;31m'
set LESS_TERMCAP_me '\E[0m'
set LESS_TERMCAP_se '\E[0m'
set LESS_TERMCAP_so '\E[01;44;37m'
set LESS_TERMCAP_ue '\E[0m'
set LESS_TERMCAP_us '\E[01;33m'

nothing changes anywhere

walles commented 5 months ago

From moar --help:

  -style value
        Highlighting style from https://xyproto.github.io/splash/docs/longer/all.html

Does this help? You should pass moar a style listed on that page.

postsolar commented 5 months ago

I set it using fish shell with "set" but it does not change anything in the man page.

Fish variables are not exported by default. For moar and other programs to know about these, you'd need to use set -x to make them exported. If you don't want to type it each time you can add it to your ~/.config/fish/config.fish, or use set -Ux. If you type help set in your fish shell you'll have the docs for this command open up.

walles commented 5 months ago

On a related note, the latest release...

https://github.com/walles/moar/releases/tag/v1.22.2

... will syntax highlight man page headings as GenericHeading, making man pages look a bit nicer even without any configuration.

walles commented 5 months ago

On a related note, the latest release...

https://github.com/walles/moar/releases/tag/v1.22.2

... will syntax highlight man page headings as GenericHeading, making man pages look a bit nicer even without any configuration.

Here's what man moar looks like for me without any LESS... variables set and no --style option. This is with moar v1.22.2.

Skärmavbild 2024-01-11 kl  12 05 07
BarbzYHOOL commented 5 months ago

how is that good looking? it's just white, i see no difference except it's white lol

I told you I tried the "--style x" and it did nothing, I retried "--style witchhazel" and it did nothing

set -x changes nothing at all, I knew it but i tried just in case, cannot say I haven't tried everything here...

set -e LESS_TERMCAP_mb
set -e LESS_TERMCAP_md
set -e LESS_TERMCAP_me
set -e LESS_TERMCAP_se
set -e LESS_TERMCAP_so
set -e LESS_TERMCAP_ue
set -e LESS_TERMCAP_us

set -x LESS_TERMCAP_mb '\E[01;31m'
set -x LESS_TERMCAP_md '\E[01;31m'
set -x LESS_TERMCAP_me '\E[0m'
set -x LESS_TERMCAP_se '\E[0m'
set -x LESS_TERMCAP_so '\E[01;44;37m'
set -x LESS_TERMCAP_ue '\E[0m'
set -x LESS_TERMCAP_us '\E[01;33m'

image

image

tell me if i'm wrong

walles commented 5 months ago

You must change the environment in the same terminal tab where you're running moar.

If you are changing the variables in one tab and running moar in the another that would explain a lot of the problems you're seeing here.

Also, '\E[01;31m' won't fly, if you're on fish you have to do \x1b'[01;31m'.

BarbzYHOOL commented 5 months ago

I never ran it in another tab lol, I set env variables for 10 years without issues

\x1b'[01;31m' no idea what all that stuff is, I've tried tons of different color codes from different pages, spent 1 hour testing all of them

I replaced by that thing and it still does nothing at all

set -x LESS_TERMCAP_mb \x1b'[01;31m'
set -x LESS_TERMCAP_md \x1b'[01;31m'
postsolar commented 5 months ago

set -x MANROFFOPT '-c' should do the trick. But LESS_TERMCAP_so should work for the statusline even without it.

@walles I think $MANROFFOPT could be included in debug output the same way as $LESS_TERMCAP_* variables? From what I understand it's an obscure setting with very few mentions on the internet, and not all distros put it in /etc/profile or not all man implementations set -c as default, e.g. on Nix it seems it's not the case. But at the same time it influences behavior of moar the same way as $LESS_TERMCAP_*. It could be quite confusing. To quote man man on it:

  MANROFFOPT
         Every time man invokes the formatter (nroff, troff, or groff), it adds the contents of $MANROFFOPT to the formatter's command line.

To be extra clear, this would be an issue with less too. On my system, if I unset this variable neither moar nor less will display colors of the man pages (i.e. none but the status bar), even if less variables are correctly set.

walles commented 5 months ago

v1.23.1 fixes one problem in moar related to LESS_TERMCAP_xx handling.

Reopening this ticket since the discussion is still ongoing.

BarbzYHOOL commented 5 months ago

set -x MANROFFOPT '-c' changes nothing again

I updated moar and now the color changed a little as you pointed in your screenshot @walles it is now whiter than greyer ^^but that's all

walles commented 5 months ago

Try this (assuming you're using fish as your shell):

LESS_TERMCAP_md=\x1b'[01;31m' man moar
  1. If this has no effect, then this is a problem with moar
  2. If this makes certain text red, then this is a problem with your environment

Here's what this looks like to me:

red-man-page
BarbzYHOOL commented 5 months ago

image image

Same thing again

Or gimme the commands for bash and i'll try in bash.

Just in case, i TRIED THe same command in bash and here is the result, it's different and there is a background color (probably default) when searching...

image

walles commented 5 months ago

Try this: LESS_TERMCAP_md=\x1b'[01;31m' moar --help.

In the most recent versions of moar this should tell you what moar thinks of the LESS_TERMCAP_xx environment variables. Please send me the complete output of that command.

BarbzYHOOL commented 5 months ago
Usage
  moar [options] <file>
  ... | moar
  moar < file

Shows file contents. Compressed files will be transparently decompressed.
Input is expected to be (possibly compressed) UTF-8 encoded text. Invalid /
non-printable characters are by default rendered as '?'.

More information + source code:
  <https://github.com/walles/moar#readme>

Environment
  Additional options are read from the MOAR environment variable.
  Current setting: MOAR="-wrap -colors 16M"
  LESS_TERMCAP_md (man page bold style): ESC[01;31m

Making moar Your Default Pager
  Put the following line in your ~/.bashrc, ~/.bash_profile or ~/.zshrc
  and moar will be used as the default pager in all new terminal windows:

     export PAGER=moar

Options
  -colors value
        Highlighting palette size: 8, 16, 256, 16M, auto
  -debug
        Print debug logs after exiting
  -follow
        Follow piped input just like "tail -f"
  -lang value
        File contents, used for highlighting. Mime type or file extension ("html"). Default is to guess by filename.
  -mousemode mode
        Mouse mode: auto, select or scroll: https://github.com/walles/moar/blob/master/MOUSE.md
  -no-clear-on-exit
        Retain screen contents when exiting moar
  -no-linenumbers
        Hide line numbers on startup, press left arrow key to show
  -no-statusbar
        Hide the status bar, toggle with '='
  -quit-if-one-screen
        Don't page if contents fits on one screen
  -render-unprintable value
        How unprintable characters are rendered: highlight or whitespace
  -scroll-left-hint value
        Shown when view can scroll left. One character with optional ANSI highlighting.
  -scroll-right-hint value
        Shown when view can scroll right. One character with optional ANSI highlighting.
  -shift amount
        Horizontal scroll amount >=1, defaults to 16
  -statusbar style
        Status bar style: inverse, plain or bold
  -style style
        Highlighting style from https://xyproto.github.io/splash/docs/longer/all.html
  -trace
        Print trace logs after exiting
  -version
        Prints the moar version number
  -wrap
        Wrap long lines
  +1234
        Immediately scroll to line 1234
walles commented 5 months ago

Does this give you the color you ask for (still fish)?

PAGER=moar LESS_TERMCAP_md=\x1b'[01;31m' man moar

The help text indicates moar is not your current pager, or at least this version of moar isn't. Otherwise it wouldn't show the "Making moar Your Default Pager" section.

You might be using some other installation of moar as your PAGER.

Also, please do moar --version so I know where we are.

postsolar commented 5 months ago

At least on some systems MANPAGER has precedence over PAGER, so MANPAGER=less PAGER=moar man moar will open less. I'd recommend running man moar | moar instead. Or like this for more assurance (assuming fish):

> set -e MANROFFOPT MANPAGER PAGER LESS_TERMCAP_mb LESS_TERMCAP_md LESS_TERMCAP_me LESS_TERMCAP_se LESS_TERMCAP_so LESS_TERMCAP_ue LESS_TERMCAP_us LESS LESSKEYIN_SYSTEM LESS LESSOPEN MOAR
> MANROFFOPT='-c' man moar | LESS_TERMCAP_md=\e'[01;31m' moar
> MANROFFOPT='-c' man moar | LESS_TERMCAP_md=\e'[01;31m' less
BarbzYHOOL commented 5 months ago

Does this give you the color you ask for (still fish)?

PAGER=moar LESS_TERMCAP_md=\x1b'[01;31m' man moar

The help text indicates moar is not your current pager, or at least this version of moar isn't. Otherwise it wouldn't show the "Making moar Your Default Pager" section.

You might be using some other installation of moar as your PAGER.

Also, please do moar --version so I know where we are.

On fish you cannot put the export command like that, obviously it's the default pager since it opens moar when I type "man". Most likely your code tries to verify if it is set only on bash shells. Hmm, in fact, I did something a bit special, lol. I set $PAGER to pager and set it as moar with update-alternatives command. I don't remember why but there was a purpose and maybe that's why it doesn't detect

My moar version is v1.23.3

@postsolar all the commands I press here open Moar, I can see the difference and you too from my screenshots

Ok so I pasted the last block of commands without trying to understand what it does. First of all, can you tell me why some people share commands with a > before (or another character)? Secondly, here is the result, the top part of the screenshot is using these commands, the bottom one is normal moar

image

So the top terminalfinally has some background on search (but i lost the blue color on bold words)

postsolar commented 5 months ago

On fish you cannot put the export command like that

You can since version 3.1.0

First of all, can you tell me why some people share commands with a > before (or another character)?

Don't know about others, or if it's an explicit convention, but I use it to indicate what is the command and what is the output, for example:

> echo 123
123

You'll also see $ used. There's also a convention that # prefix indicates running a command as root.

Ok so I pasted the last block of commands without trying to understand what it does

Well set -e ... you already know, the other two run moar and less with the right variables to see if it helps.

But what about less, does it look the same? Also, what distro are you on and which terminal do you use? And could you share your terminal's colorscheme (perhaps use fastfetch or neofetch to generate it)?

walles commented 5 months ago

@BarbzYHOOL maybe we should do a Google Meet call about this?

E-mail me (or send a calendar invite to) johan.walles@gmail.com. As for times let's try starting between 08:30CET and 20:00CET.

Seeing your screen live and talking to you directly would make this a lot easier to figure out I think.

BarbzYHOOL commented 5 months ago

@postsolar here is what LESS looks with your command, a bit a different than MOAR image

I'm on POPOS 22.04 using Tilix, maybe it's a bug with the terminal??

Here is my color scheme (custom) image

@walles i cannot be there at these hours and I don't have this thing google meet (nor microphone)