Skip to content

fix: respect NO_COLOR and TERM=dumb environment variables#764

Merged
djc merged 1 commit intoconsole-rs:mainfrom
shaanmajid:fix/respect-no-color-term-dumb
Feb 4, 2026
Merged

fix: respect NO_COLOR and TERM=dumb environment variables#764
djc merged 1 commit intoconsole-rs:mainfrom
shaanmajid:fix/respect-no-color-term-dumb

Conversation

@shaanmajid
Copy link
Contributor

@shaanmajid shaanmajid commented Feb 3, 2026

Fixes #763

Changes is_hidden() and drawable() to check term.features().colors_supported() instead of term.is_term(). The console crate's colors_supported() already checks for NO_COLOR and TERM=dumb, so this change makes indicatif respect those signals.

Test plan

Use the MRE from #763 with a path dependency:

indicatif = { path = "path/to/fix/branch/indicatif" }

script creates a pseudo-TTY so isatty() returns true. Grepping for 1b 5b (hex ESC[) detects ANSI escape sequences. With the fix, no output should appear when TERM=dumb or NO_COLOR=1.

# Normal TTY - escape sequences expected
script -q /dev/null ./target/release/mre 2>&1 | xxd | grep '1b 5b'
# Output: 00000050: ... 0d1b 5b32 4b ...  (ESC[2K present)

# With TERM=dumb - escape sequences should be suppressed
TERM=dumb script -q /dev/null ./target/release/mre 2>&1 | xxd | grep '1b 5b'
# No output expected

# With NO_COLOR=1 - escape sequences should be suppressed
NO_COLOR=1 script -q /dev/null ./target/release/mre 2>&1 | xxd | grep '1b 5b'
# No output expected

@shaanmajid shaanmajid force-pushed the fix/respect-no-color-term-dumb branch from eed5812 to 92be8a4 Compare February 4, 2026 20:00
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! @chris-laplante is there anything I'm missing here?

@chris-laplante
Copy link
Collaborator

I like it! @chris-laplante is there anything I'm missing here?

Looks nice and simple to me :)

@djc djc merged commit 8e0ab0e into console-rs:main Feb 4, 2026
11 checks passed
@shaanmajid shaanmajid deleted the fix/respect-no-color-term-dumb branch February 4, 2026 21:11
@shaanmajid
Copy link
Contributor Author

Thanks y'all :)

@j178
Copy link

j178 commented Feb 4, 2026

Thanks! Any chance we could get a release for this?

@djc
Copy link
Member

djc commented Feb 5, 2026

We can definitely do a release soon. There's one more potential fix I'd like to wait for (if it doesn't take too long).

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

Successfully merging this pull request may close these issues.

Progress bar visibility does not respect TERM=dumb or NO_COLOR=1

4 participants

Comments