Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add terminal color check #184

Merged
merged 1 commit into from
Dec 16, 2024
Merged

feat: add terminal color check #184

merged 1 commit into from
Dec 16, 2024

Conversation

hengyoush
Copy link
Owner

add terminal color check

Copy link

vercel bot commented Dec 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kyanos ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 5:47pm

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 16, 2024
Copy link

Deploying kyanos with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5c41260
Status: ✅  Deploy successful!
Preview URL: https://52eef29f.kyanos.pages.dev
Branch Preview URL: https://check-term-color.kyanos.pages.dev

View logs

@dosubot dosubot bot added the enhancement New feature or request label Dec 16, 2024
@hengyoush hengyoush merged commit a1a834b into main Dec 16, 2024
13 checks passed
Comment on lines +8 to +11
func Is256ColorSupported() bool {
term := os.Getenv("TERM")
return strings.Contains(term, "256color")
}
Copy link

@ccoVeille ccoVeille Dec 16, 2024

Choose a reason for hiding this comment

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

I'm sorry but this check is way too naive

Take a look at project that could help you to detect that capabilities

https://pkg.go.dev/github.com/gookit/color#IsSupport256Color

The simplest would be to use this

https://pkg.go.dev/github.com/muesli/termenv#DefaultOutput

Then call ColorProfile

https://pkg.go.dev/github.com/muesli/termenv#Output.ColorProfile

Copy link
Owner Author

@hengyoush hengyoush Dec 17, 2024

Choose a reason for hiding this comment

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

Thank you for pointing out the issues! I'll modify this part of the code later.

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:S This PR changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants