glow icon indicating copy to clipboard operation
glow copied to clipboard

Garbled output with -p and most

Open reitzig opened this issue 2 years ago • 5 comments

I want to read a markdown file pager-style, not by scrolling in the shell. So I use -p; most is my pager. Compare:

glow -p README.md: image

glow README.md: image

glow README.md | most image

Workaround: glow . or glow --all and select the file.

Not sure whether the problem is actually with glow, not most (most does show colors in other cases, e.g. when showing man pages). So I guess I'll spin this as a feature request: please add an option (that I can make the default through the config file) that opens the given file in "pager mode" directly (without the external pager).

❯ glow --version
glow version 1.4.1 (4863f57)
❯ most --version
MOST version 5.0.0 (S-Lang version 2.3.2)
 *Note: This executable was compiled against S-Lang 2.3.1

reitzig avatar Mar 23 '22 22:03 reitzig

Pretty sure these are ansi codes that your pager is not configured to recognize. Search the internet or the less docs for the less -r and see if there's an equivalent flag for most

zach-is-my-name avatar Mar 28 '22 04:03 zach-is-my-name

I was only looking for color (which are turned on automatically for most); searching for "control characters", -v might help. But how do I test that? I don't see a way to pass pager flags t glow; it'd have to add the option automatically on -p the way it does for less, wouldn't it?

I'd still rather go to glow's "pager" directly, anyway, instead of printing to the shell. Should I open a separate ticket for that?

reitzig avatar Mar 28 '22 07:03 reitzig

You can set the flags in less in their env's or you can also pipe to glow with glow -. As in cat README.md | glow -

zach-is-my-name avatar Mar 28 '22 07:03 zach-is-my-name

I don't think I've made myself understood. Let me try again.

  • I use most, not less.
  • I don't actually want to use glow with most, or any pager.
  • What I want is pager-style Markdown viewing. glow can do that -- but doesn't when I call it with a file (or stdin, for that matter). I have to open the directory in glow, then select the file.
  • glow -p, my last resort, doesn't work with most.

The last item -- the actual concern of the OP -- might be fixed by adding one flag or another to the call to most in glow (see also #250), or to change the output in a compatible way (depending on the pager?). I checked the man page of most; there actually is MOST_SWITCHES but none of the available options helps.

The actual issue would be addressed by changing glow so that there's way to directly get to the result as described in the workaround in the second-to-last item.

reitzig avatar Mar 29 '22 22:03 reitzig

What I did: set MANPAGER to most (so now only man uses most) and PAGER to less -r (which apparently is the default used by glow if pager is unset. You could also unset PAGER to have the same effect).

Not really a solution, but it should get you up and running at least...

gtsiam avatar May 05 '22 13:05 gtsiam

I think this may just be a most version that doesn't support RGB colors yet - the most recent releases do however.

As such, I can't reproduce this issue anymore, but here are a few tips:

  • if you unset your COLORTERM environment variable to yes or true, glow should default to rendering ANSI256 colors, which your version of most should understand. In such cases setting the PAGER to most works fine.

  • piping glow's output to other programs will disable styles and color rendering, as it detects not being connected to a terminal. You can override this by setting CLICOLOR_FORCE to true.

muesli avatar Oct 12 '22 00:10 muesli