Example running clear in IEx doesn't clear screen in new Windows Terminal that currently in preview. You have to run Application.put_env(:elixir, :ansi_enabled, true) to make it work. Windows Terminal (Preview) can be downloaded from Microsoft Store.
IEx to detect that it's run in new Windows Terminal and enable ANSI escape codes by default,
How to detect https://stackoverflow.com/questions/59733731/how-do-detect-if-running-in-the-new-windows-terminal
You can check for the WT_SESSION environmental variable which is set to a v4 UUID: https://github.com/microsoft/terminal/issues/1040
If you're looking for a quick and dirty way to check, this should work:
!!process.env.WT_SESSION
There's also a more elaborate method you can use, taking advantage of is-uuid and process.platform:
const isUUID = require("is-uuid") process.platform === "win32" && isUUID.v4(process.env.WT_SESSION)
Feature Request: Clients of terminal need a way to inquire about the capabilities of the terminal https://github.com/microsoft/terminal/issues/1040
Is there a way to detect if the terminal supports ANSI codes other than checking specific environment variables for every terminal?
We would love some help on this one. So what you need to do is something here:
https://github.com/elixir-lang/elixir/blob/master/bin/elixir.bat#L155
Something like:
if somehow_check_if_we_are_in_new_windows_terminal_and_ansi_is_enabled (
set beforeExtra=-elixir -ansi_enabled true
)
/cc @OnorioCatenacci @OvermindDL1
For completeness, here is how this test looks like on Unix:
https://github.com/elixir-lang/elixir/blob/master/bin/elixir#L209-L211
I also noticed another thing when I run in h in IEx under Windows Terminal after Application.put_env(:elixir, :ansi_enabled, true) asterisk * will be printed as ΓÇó. Any idea why this is happening?
I haven't even gotten a chance to play with the new terminal yet so I guess
this is a good excuse to do that!
On Tue, Feb 11, 2020 at 1:20 PM José Valim notifications@github.com wrote:
We would love some help on this one. So what you need to do is something
here:https://github.com/elixir-lang/elixir/blob/master/bin/elixir.bat#L155
Something like:
if somehow_check_if_we_are_in_new_windows_terminal_and_ansi_is_enabled (
set beforeExtra=-elixir -ansi_enabled true
)/cc @OnorioCatenacci https://github.com/OnorioCatenacci @OvermindDL1
https://github.com/OvermindDL1—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/elixir-lang/elixir/issues/9810?email_source=notifications&email_token=AABFOFLLNDBVBXQDPUF3O5LRCLT5PA5CNFSM4KTFLGKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELNQFQI#issuecomment-584778433,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABFOFNOHWSRCLKJJZGF76TRCLT5PANCNFSM4KTFLGKA
.
HI all,
I've got the preview terminal; I have been trying to figure out how to
check for the new windows terminal and also check if ansi is enabled.
On Tue, Feb 11, 2020 at 1:20 PM José Valim notifications@github.com wrote:
We would love some help on this one. So what you need to do is something
here:https://github.com/elixir-lang/elixir/blob/master/bin/elixir.bat#L155
Something like:
if somehow_check_if_we_are_in_new_windows_terminal_and_ansi_is_enabled (
set beforeExtra=-elixir -ansi_enabled true
)/cc @OnorioCatenacci https://github.com/OnorioCatenacci @OvermindDL1
https://github.com/OvermindDL1—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/elixir-lang/elixir/issues/9810?email_source=notifications&email_token=AABFOFLLNDBVBXQDPUF3O5LRCLT5PA5CNFSM4KTFLGKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELNQFQI#issuecomment-584778433,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABFOFNOHWSRCLKJJZGF76TRCLT5PANCNFSM4KTFLGKA
.
You know Jose, something just occurred to me. When I run cargo build in
Rust, the output is in color. And I'm running it from a normal cmd
prompt. I should see how they get their output. I mean if they can do it
from a normal cmd prompt we should be able to do it too.
On Wed, Feb 26, 2020 at 10:12 AM Onorio Catenacci <
[email protected]> wrote:
HI all,
I've got the preview terminal; I have been trying to figure out how to
check for the new windows terminal and also check if ansi is enabled.On Tue, Feb 11, 2020 at 1:20 PM José Valim notifications@github.com
wrote:We would love some help on this one. So what you need to do is something
here:https://github.com/elixir-lang/elixir/blob/master/bin/elixir.bat#L155
Something like:
if somehow_check_if_we_are_in_new_windows_terminal_and_ansi_is_enabled (
set beforeExtra=-elixir -ansi_enabled true
)/cc @OnorioCatenacci https://github.com/OnorioCatenacci @OvermindDL1
https://github.com/OvermindDL1—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/elixir-lang/elixir/issues/9810?email_source=notifications&email_token=AABFOFLLNDBVBXQDPUF3O5LRCLT5PA5CNFSM4KTFLGKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELNQFQI#issuecomment-584778433,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABFOFNOHWSRCLKJJZGF76TRCLT5PANCNFSM4KTFLGKA
.
@OnorioCatenacci it is possible to do it if you invoke some commands on the terminal:
In 2016, Microsoft released the Windows 10 Version 1511 update which unexpectedly implemented support for ANSI escape sequences.[13] The change was designed to complement the Windows Subsystem for Linux, adding to the Windows Console Host used by Command Prompt support for character escape codes used by terminal-based software for Unix-like systems. This is not the default behavior and must be enabled programmatically with the Win32 API via SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING).[14] This was enabled by CMD.EXE but not initially by PowerShell;[15] however, Windows PowerShell 5.1 now enables this by default. The ability to make a string constant containing ESC was added in PowerShell 6 with (for example) "`e[32m";[16] for PowerShell 5 you had to use [char]0x1B+"[32m".
Windows Terminal, introduced in 2019, supports the sequences by default, and it appears Microsoft intends to merge or replace Windows Console with it.
Although they have enabled it by default on recent powershell, so I can give it a try. I also tried to give the Windows Terminal a look but it requires both: creating a Microsoft Store account and join their "Insider Program". Given the amount of hops Microsoft has put in place for people to try it out, unfortunately I won't be able to investigate it.
Closing in favor of #10031.
When Running 11-dev on windows10, after having runreg add HKCU\\Console /v VirtualTerminalLevel /t REG_DWORD /d 1 and re-started my conEmu console, I get the following warning / error in red - confirming that the colors are working ...
λ iex -S mix
Cannot configure base applications: [:elixir]
These applications are already started by the time Mix loads
and therefore these configurations have no effect.
If you want to configure these applications for a release,
wrap them in a condition, such as:
if System.get_env("RELEASE_MODE") do
config :kernel, ...
end
Alternatively, specify the configuration values in your vm.args file:
-elixir ansi_enabled true
I don't have any :elixir configs in my .iex.exs file
Are you inside a project? If so, is there any file in config/*.exs that configures the Elixir application?
yes, i have config/*.exs
import Config
config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase
config :logger, :console,
format: "[$date $time] $message\n",
colors: [enabled: true, debug: :normal]
I see your point
It is a bug in Elixir. That config should be fine. I will fix it.