ayi <p>How to echo with different colors in the Windows command line</p> <hr> <p><em>Source : <a href="http://cmder.net/" rel="noopener nofollow ugc">Stack Overflow [windows]</a>,)</em></p>
ayi_2 <p>I wanted to to print one single line in a different color.</p> <p>Use ANSI Escape Sequences.</p> <p><strong>Windows before Windows 10 - no native support for ANSI colors on the console</strong></p> <p>For Windows version below 10, the Windows command console doesn’t support output coloring by default. You could install either <a href="http://cmder.net/">Cmder</a>, <a href="https://conemu.github.io/">ConEmu</a>, <a href="https://github.com/adoxa/ansicon/releases">ANSICON</a> or <a href="https://mintty.github.io/">Mintty</a> (used by default in GitBash and Cygwin) to add coloring support to your Windows command console.</p> <p><strong>Windows 10 and later - Command Line Colors</strong></p> <p>Starting from Windows 10 the Windows console support ANSI Escape Sequences and some colors by default. The feature shipped with the Threshold 2 Update in Nov 2015.</p> <p><strong><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx">MSDN Documentation</a></strong></p> <p><strong>Update</strong> (05-2019): The <a href="https://github.com/Microsoft/Terminal/tree/master/src/tools/ColorTool">ColorTool</a> enables you to change the color scheme of the console. It’s part of the Microsoft <a href="https://github.com/microsoft/Terminal">Terminal</a> project.</p> <p><strong>Demo</strong></p> <p><a href="https://i.sstatic.net/gpDPE.png"></a></p> <p><strong>Batch Command</strong></p> <p>The <a href="https://gist.github.com/mlocati/fdabcaeb8071d5c75a2d51712db24011#file-win10colors-cmd"><code>win10colors.cmd</code></a> was written by <a href="https://github.com/mlocati">Michele Locati</a>:</p> <p><img src="https://forum-microsoft.fr/images/emoji/twitter/bellhop_bell.png?v=15" title=":bellhop_bell:" class="emoji only-emoji" alt=":bellhop_bell:" loading="lazy" width="20" height="20"><em>The text below is stripped of special characters and will not work. You must copy it from <a href="https://gist.githubusercontent.com/mlocati/fdabcaeb8071d5c75a2d51712db24011/raw/b710612d6320df7e146508094e84b92b34c77d48/win10colors.cmd">here</a>.</em></p> <pre><code class="lang-auto">@echo off cls echo [101;93m STYLES [0m echo ^<ESC^>[0m [0mReset[0m echo ^<ESC^>[1m [1mBold[0m echo ^<ESC^>[4m [4mUnderline[0m echo ^<ESC^>[7m [7mInverse[0m echo. echo [101;93m NORMAL FOREGROUND COLORS [0m echo ^<ESC^>[30m [30mBlack[0m (black) echo ^<ESC^>[31m [31mRed[0m echo ^<ESC^>[32m [32mGreen[0m echo ^<ESC^>[33m [33mYellow[0m echo ^<ESC^>[34m [34mBlue[0m echo ^<ESC^>[35m [35mMagenta[0m (Réponse tronquée)</code></pre>