Skip to content

Enable console output target on Windows by default#88

Open
Joannis wants to merge 2 commits intoonevcat:masterfrom
Joannis:jo/windows
Open

Enable console output target on Windows by default#88
Joannis wants to merge 2 commits intoonevcat:masterfrom
Joannis:jo/windows

Conversation

@Joannis
Copy link

@Joannis Joannis commented Dec 20, 2025

Fixes #87

Modern Windows terminals (Windows 10+, Windows Terminal, PowerShell) support ANSI escape codes. This change enables colored output by default on Windows by returning .console as the detected output target.

Changes

  • Added #if os(Windows) conditional compilation to return .console directly on Windows
  • Keeps existing TTY detection behavior on other platforms

@onevcat
Copy link
Owner

onevcat commented Jan 6, 2026

Hi @Joannis, thanks for the PR! I don’t have any Windows experience, so I’d love your advice here. Would it make sense to add a TTY check on Windows to avoid emitting ANSI escape codes when output is redirected to a file/pipe? I’m thinking something like:

#if os(Windows)
return isatty(fileno(stdout)) != 0 ? .console : .unknown
#else
// existing TERM + isatty logic
#endif

If that’s reasonable, I’d prefer to keep the default behavior consistent across platforms for TTY vs file output. Let me know what you think.

@Joannis
Copy link
Author

Joannis commented Jan 8, 2026

I can try that, IIRC Windows' terminals don't have all of the APIs you'd expect so I'm not certain isatty is available.

@Joannis
Copy link
Author

Joannis commented Jan 19, 2026

Hey @onevcat , sorry about the delay. Was not paying attention too much - but I've updated it

@Joannis
Copy link
Author

Joannis commented Jan 19, 2026

I forgot Windows likes to underscore symbols

@Joannis
Copy link
Author

Joannis commented Feb 10, 2026

Ping @onevcat

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.

Default OutputTarget.current is not .console on Windows

2 participants