feat: auto-detect non-TTY and adjust output (bd-xrwy)

Add TTY detection to automatically disable ANSI colors when stdout is
piped or redirected. Respects standard conventions:
- NO_COLOR environment variable (no-color.org)
- CLICOLOR=0 disables color
- CLICOLOR_FORCE enables color even in non-TTY

Also adds ShouldUseEmoji() helper controlled by BD_NO_EMOJI.
Pager already disabled non-TTY in previous work (bd-jdz3).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 06:58:50 -08:00
parent 06c8855873
commit f6f9ef260d
3 changed files with 199 additions and 0 deletions

View File

@@ -7,8 +7,16 @@ import (
"strings"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
)
func init() {
// Disable colors when not appropriate (non-TTY, NO_COLOR, etc.)
if !ShouldUseColor() {
lipgloss.SetColorProfile(termenv.Ascii)
}
}
// Ayu theme color palette
// Dark: https://terminalcolors.com/themes/ayu/dark/
// Light: https://terminalcolors.com/themes/ayu/light/