oz / tz

🌐 A time zone helper
GNU General Public License v3.0
849 stars 33 forks source link

[bug] When TERM is set to xterm, colors are not displaying properly #55

Open lunrenyi opened 4 weeks ago

lunrenyi commented 4 weeks ago
jnd-au commented 4 weeks ago

What is your real TERM in which you are running docker? Use -e TERM to provide your terminal type to docker. Otherwise, https://github.com/muesli/termenv detects the default value TERM=xterm as a generic non-colour terminal because the docker container doesn’t know your real environment.

lunrenyi commented 4 weeks ago

In my Mac environment, TERM=xterm tz displays correctly, but it doesn't show up properly within a Docker Ubuntu image.

jnd-au commented 4 weeks ago

This suggests your macOS terminal environment has additional environment variables set (termenv detects these). Whereas docker run wipes the environment information by default, so differences should be expected. Normally, TERM=xterm tz on macOS is black-and-white, same as Docker.

jnd-au commented 4 weeks ago

Also, which version of tz -v are you using in each environment? (E.g. macOS Homebrew currently has version 0.7.0, but I’m not sure what you’re using within Docker.)

lunrenyi commented 4 weeks ago

Also, which version of tz -v are you using in each environment? (E.g. macOS Homebrew currently has version 0.7.0, but I’m not sure what you’re using within Docker.)

They are all version 0.7.0, sourced from https://github.com/oz/tz/releases/tag/v0.7.0

jnd-au commented 4 weeks ago

I also have 0.7.0 and it works as expected: uncoloured with TERM=xterm, 16-colour with TERM=xterm-colour, and 256-colour with TERM=xterm-256color. The differences in your screenshots are probably due to the discrepancies between your environments. If you align your environments, you should see the same.

jnd-au commented 4 weeks ago

Hi @lunrenyi if you’re using iTerm, it sets some environment variables like COLORTERM=truecolor and TERM=xterm-256color which are different inside the Ubuntu Docker container, hence the discrepancy. If you pass your COLORTERM to docker, it will override TERM=xterm for colour detection, and tz will give you the result you expect: docker run -e COLORTERM .... Regards