Skip to content
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

colors not displayed with TERM=xterm #35

Open
taviso opened this issue Aug 19, 2024 · 4 comments
Open

colors not displayed with TERM=xterm #35

taviso opened this issue Aug 19, 2024 · 4 comments

Comments

@taviso
Copy link

taviso commented Aug 19, 2024

I notice that keyb does not use any colors with TERM=xterm, but it does work with TERM=xterm-color.

I usually just use TERM=xterm, can I force keyb to use colors without changing my $TERM?

(Note: This used to work with v0.3, I just upgraded to v0.7 and lost colors)

@kencx
Copy link
Owner

kencx commented Aug 19, 2024

Hi, thanks for opening an issue. Could you share the following information:

  • OS
  • Terminal Emulator
  • With tmux?
  • Environment variables:
    • TERM
    • COLORTERM
    • TERM_PROGRAM
    • CI
    • CLICOLOR
    • NO_COLOR

This is most likely an issue with the underlying color libraries termenv or lipgloss as these were updated since v0.3.

@taviso
Copy link
Author

taviso commented Aug 19, 2024

Thanks, I'm using Ubuntu 22.04.4 LTS and XTerm 393, without tmux/screen.

  • Environment:
    • TERM=xterm
    • COLORTERM unset
    • TERM_PROGRAM unset
    • CI unset
    • CLICOLOR unset
    • NO_COLOR unset

The other features all seem to work!

@taviso
Copy link
Author

taviso commented Aug 19, 2024

Hmm, CLICOLOR_FORCE=1 keyb does work as a workaround, I guess that's okay... although I think most xterm users just use the default XTerm $TERM name, so won't realize there are colors!

@kencx
Copy link
Owner

kencx commented Aug 23, 2024

I managed to replicate this with xterm and the examples in termenv.

  • With default TERM=xterm xterm, termenv's hello-world example returns no colors as the color profile is ASCII.
  • With CLICOLOR_FORCE=1 TERM=xterm xterm, there are colors as the color profile switches to ANSI256.
  • With TERM=xterm xterm +cm, the color profile is ANSI256 as the +cm flag enables support for ANSI escape sequences. Edit: My bad, this doesn't actually work.

However, you mentioned that colors were working before in v0.3.0. I didn't manage to replicate that - colors were still not working for me with the default TERM=xterm xterm and the rest of the behaviour was exactly the same as above.

For the fix, I could add the following:

if termenv.EnvColorProfile() == termenv.Ascii {
    lipgloss.SetColorProfile(termenv.ANSI256)
}

but I don't feel comfortable messing with the user's terminal configuration. Instead, I'll probably just add a note with the workaround above for xterm users or any other users that lack colors.

Edit: Might be a good idea to implement this in the future, but the current workaround seems simple enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants