-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force color output? #440
Comments
After poking around in the code, I noticed that if I explicitly set a style, it will be used regardless of whether or not we're writing to a terminal. That works, but you lose the ability to detect light vs. dark style. |
Setting |
|
Omitting |
Make sure that |
It seems like when using a custom theme, I need to specify the theme every time I want to force color output. The ability to force color output would be very helpful and save me from having to hardcode the path to my custom theme I want in things like shell scripts and aliases rather than just specifying it once in glow's config file. |
you can force by setting |
This seems to be new behavior since 2.0 I guess, whereas previously specifying a style was enough to ensure use of that style when piped. IMO it's worth a note on the GH release item. |
though colors are still unreadable sometimes See charmbracelet/glow#440 (comment)
This is because when terminal output is not detected, and |
Should it instead reuse the logic from https://github.com/muesli/termenv/blob/master/termenv_unix.go#L23 ? That checks |
I've also had this issue for some time now. Since 1407793, colors broke when glow is used as an fzf previewer. Here's an example Test file: # _Italic title_ Script: #!/usr/bin/env bash
function preview {
# broken since commit 1407793
# before commit 1407793, I was using this command:
# glow --style=auto "$1"
# half-broken since commit 1407793, italic text but no color
# glow --style=dark "$1"
# almost works since 1407793 but wrong colors
export CLICOLOR_FORCE=1
export COLORTERM=truecolor
glow --style=dark "$1"
}
export -f preview
fzf --preview "bash -c 'preview {}'" How it looked before with How it looks now with |
Oof, thanks for the heads up @AndydeCleyre and @mgnsk. This looks like a regression. Mind opening an issue accordingly? |
Has anyone found any solutions? I'm trying to use glow for markdown editing via |
glow2 broke color rendering when the output is redirected: charmbracelet/glow#440
I'd like to use glow to preview markdown output in ranger-fm. However, it seems that when the output is sent to a pipe or redirected to a file, all the ansi codes are stripped off. This seems reasonable when you just want to save the output to a file or perform greps, etc. However, is there some flag to force the ansi codes to be retained?
The text was updated successfully, but these errors were encountered: