Is it possible to colour the console output with OCaml on Windows ?
It seems to be possible on a linux terminal : print_string "\027[31m blabla"
but I cannot find any information regarding the Windows console.
Is it possible to colour the console output with OCaml on Windows ?
It seems to be possible on a linux terminal : print_string "\027[31m blabla"
but I cannot find any information regarding the Windows console.
Color management is not possible by default using the command ( ms dos ) console emulation.
Out of the box, the best you can get is by using the PowerShell command line interface instead and to configure the colors like explained in this page.
In an opened terminal:
write-host -foregroundcolor Red "Hello"
will result in Hello printed in Red ...
But this is not convenient at all..
The easiest way is to uses an external tool to do the job, but you'll need to install a kind of windows command line extension. A nice project can be found HERE it's called ANSICON and will directly interpret the ANSI codes the same way the Linux modern terminal emulators does.
You may be interested in ANSITerminal . I do not remember how good the Windows version is — I personally do not use that platform — but do not hesitate to fill issues or submit pull requests.
If you are looking for ANSI color support (and more) in cmd.exe
you can use clink.