Windows – Is it possible to reset the colour after entering the command in cmd shell

bashcolorscommand lineshellwindows

I am running Windows 10 and want to set up cmd.exe prompt such that it looks the same as my bash prompt on the same machine. I have set up a startup script to set the PROMPT variable when loading cmd.exe, which detects whether the shell is running with root privileges and set up the colour accordingly:

Shell colours

However, as shown from the screenshot, I can't set up the prompt in cmd.exe (the upper windows) such that the colour resets to default after finishing the command, as shown in bash (the lower windows). If I run bash from cmd, the colour also can't reset.

Then I run ls with colours in both shells, if I run it in cmd, or bash within cmd, the colour cannot be reset by the normal file. However, if I run it in bash only, the colour can be reset.

ls colours

How can I set up my startup script such that the colour behaviour of cmd.exe is made identical to my bash shell?

Best Answer

There are some newish experimental features in the Windows 10 console that make it much more *NIX like. For example colors that are no longer constrained to the 16 that were available up until now, cursor shapes, etc.

It is configured from the properties windows as before:

enter image description here

More details can be found here:

https://devblogs.microsoft.com/commandline/new-experimental-console-features/

Related Question