How to have multiple colors in a Windows batch file?

前端 未结 12 1602
我寻月下人不归
我寻月下人不归 2020-11-22 01:05

I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says

echo hi world
12条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 01:19

    Windows 10 ((Version 1511, build 10586, release 2015-11-10)) supports ANSI colors.
    You can use the escape key to trigger the color codes.

    In the Command Prompt:

    echo ^[[32m HI ^[[0m
    

    echo Ctrl+[[32m HI Ctrl+[[0mEnter

    When using a text editor, you can use ALT key codes.
    The ESC key code can be created using ALT and NUMPAD numbers : Alt+027

    [32m  HI  [0m
    

提交回复
热议问题