Skip to content

tmux-256color with COLORTERM=truecolor detected as ANSI256 instead of TrueColor #76

@cpcloud

Description

@cpcloud

Bug description

envColorProfile() in env.go caps TERM values prefixed with tmux at ANSI256, even when COLORTERM=truecolor is set. The comment on line 187 says "Tmux doesn't support $COLORTERM", but modern tmux does — and many terminal emulators set COLORTERM=truecolor inside tmux sessions.

Setup

  • OS: Linux (NixOS)
  • Shell: zsh
  • Terminal Emulator: various (ghostty, kitty, alacritty)
  • Terminal Multiplexer: tmux 3.5a
  • TERM: tmux-256color
  • COLORTERM: truecolor

Steps to reproduce

  1. Run inside tmux with TERM=tmux-256color and COLORTERM=truecolor
  2. Call colorprofile.Detect(os.Stdout, os.Environ())
  3. Returns ANSI256 instead of TrueColor

Expected behavior

When COLORTERM=truecolor is set, the profile should be TrueColor regardless of the TERM prefix. The COLORTERM variable is the standard way for terminals to advertise truecolor support.

Additional context

The Detect() function does have a tmux() fallback that queries tmux info for Tc/RGB capabilities, but envColorProfile() is called first in many code paths (e.g. via lipgloss.HasDarkBackground). Setting TERM=xterm-256color works around the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions