Giter Site home page Giter Site logo

Comments (2)

itowlson avatar itowlson commented on May 25, 2024

This occurs because the Go terminal.IsTerminal function returns true for PowerShell terminals (see implementation at https://go.googlesource.com/crypto/+/refs/heads/master/ssh/terminal/util_windows.go). Which is fair enough because the PowerShell console is a terminal, just not one that consistently supports VT100 sequences.

Looking at https://docs.microsoft.com/en-us/windows/console/getconsolemode, I think what we're really interested in is whether the current console mode includes the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag. Obviously Go doesn't surface this from its libraries, but we could try replacing the IsTerminal call with a custom SupportsEscapeSequences function which would return IsTerminal on Unix but would additionally check the console mode on Windows. This gives a better user experience but is more invasive and risky (ripping out a stdlib function and replacing it with a custom one).

Alternatively, we could just turn colouring off entirely on Windows, i.e. the check for colouring would not be IsTerminal but IsTerminal && IsUnix.

Let me know your preference @corneliusweig - I have to admit I'm inclined to take the second option for now as it will be simpler and will still achieve the immediate goal of 'simple and well formatted.'

from rakkess.

corneliusweig avatar corneliusweig commented on May 25, 2024

Wow, thanks for your thorough investigation! You seem to be a PowerShell wizard :)

I had thoughts into the same direction, to completely turn off colors on windows. Alas, that would also turn off colors on terminals that do support colors, like the widespread git-shell. However, your idea opens up a far superior alternative. I think we should definitely try this one out -- this tool is not production critical, so it's a good test balloon. Other projects could benefit from this solution too, if it works reliably!

So let's try your idea about SupportsEscapeSequences.

from rakkess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.