charmbracelet / gum

A tool for glamorous shell scripts 🎀
MIT License
18.36k stars 348 forks source link

gum choose in screen (terminal multiplexer) does not display colors #395

Closed vt-alt closed 2 weeks ago

vt-alt commented 1 year ago

Describe the bug When run under screen (which is well known terminal multiplexer) gum choose does not highlight selected line with a color.

To Reproduce screen gum choose one two (or screen and then gum choose one two) shows both lines in gray. In the same terminal window without screen one line is magenta. In comparison in tmux colors are present (one line is magenta).

Expected behavior Hopefully colors are displayed.

Screenshots image

Desktop (please complete the following information):

Additional context screen actually can perfectly support colors 9same as tmux). But it sets TERM env variable to screen, setting TERMCAP instead. Maybe this is the cause of misbehavior? My TERM value before screen run is xterm-256color. After screen run:

$ env | grep -i term
TERM=screen
TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:li#70:co#159:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:ti=\E[?1049h:te=\E[?1049l:us=\E[4m:ue=\E[24m:so=\E[3m:se=\E[23m:mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[m:ms:Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:vb=\Eg:G0:as=\E(0:ae=\E(B:ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:po=\E[5i:pf=\E[4i:Km=\E[<:kB=\E[Z:kh=\E[1~:@1=\E[1~:kH=\E[4~:@7=\E[4~:kN=\E[6~:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:km:

Color capability is there AF=\E[3%dm.

For reference https://man.freebsd.org/cgi/man.cgi?query=termcap&sektion=5&format=html

     set_a_foreground        AF      Set ANSI foreground color
hopefulTex commented 1 year ago

It looks like this is a limitation of the termenv package, which doesn't support querying the screen colorspace as it can be hooked up to multiple terminals with different color outputs. Compatibility Chart Edit: query support is not general support

vt-alt commented 1 year ago

Thanks for looking it up! I see that CLICOLOR_FORCE=1 env could be used to force colors. But, that's pity it does not work by default in 2023.

muesli commented 1 year ago

Setting COLORTERM to an appropriate value (true or truecolor) would be enough to make it work. Alternatively start using screen-256color as your TERM.

muesli commented 1 year ago

It looks like this is a limitation of the termenv package, which doesn't support screen as it can be hooked up to multiple terminals with different color outputs. Compatibility Chart

That limitation actually only applies to querying colors.

vt-alt commented 1 year ago

Setting COLORTERM to an appropriate value (true or truecolor) would be enough to make it work.

Thanks that's also good to know.

Alternatively start using screen-256color as your TERM.

~This is actually isn't very good workaround as this is not script's job to outsmart users or system on terminal types, and for other user there could be different terminal in different circumstances (dumb terminal, 8-color, etc),~

vt-alt commented 1 year ago

Or you meant I could set my TERM after screen and before script with gum run. I will look it up. Thanks!

ps. But this will only fix issue for a single user, though.

atlas-comstock commented 1 year ago

same here, setting TERM or CLICOLOR_FORCE or COLORTERM are not work

caarlos0 commented 2 weeks ago

cannot reproduce this on latest/main.

vt-alt commented 1 week ago

OK I will try to retest on next release.