Skip to content

Windows color#76

Open
mattn wants to merge 2 commits into
svent:masterfrom
mattn:windows-color
Open

Windows color#76
mattn wants to merge 2 commits into
svent:masterfrom
mattn:windows-color

Conversation

@mattn

@mattn mattn commented Sep 10, 2016

Copy link
Copy Markdown
  • replace ssh/terminal#IsTerminal with mattn/go-isatty#IsTerminal
  • wrap os.Stdout with go-colorable.

@clach04

clach04 commented Jul 4, 2026

Copy link
Copy Markdown

Thanks for sharing this @mattn .! Bit-rot has set in; I have an experimental branch https://github.com/clach04/sift/tree/issue_92_windows_color where it merges this change with main, essentially replacing golang.org/x/term with github.com/mattn/go-colorable and github.com/mattn/go-isatty

  1. This works for me with an out-of-the-box build, colors work correctly in CMD.exe 🎉
  2. It also allows the Terminal to work when using --color flag, BUT without it it does NOT use color. So this works EXACTLY the same as current code, so no negative impact for Windows Terminal users
  3. In a CMD.exe Using --color flag does not generate color, still get the ANSI escape sequences showing as garbage as described in Issue with color on windows platform #92
  4. I've not tested this under Unix/Linux, etc.

This is likely not ready for prime time like this (as it changes some libraries) but this looks promising 😄 and if Unix works the same, then this may be worth reviewing further. I would love out of box color working for sift under Windows. The test fix from @mattn works well enough for me to be useful

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.

2 participants