4/15/2023 0 Comments Windows terminal font changeIf /i " !foreground!"= " DarkRed" set currentColor=!ESC![31m REM Foreground Colours if /i " !foreground!"= " Black" set currentColor=!ESC![30m REM This requires the setContrastForeground subroutine, which is discussed below if /i " !foreground!"= " Contrast" ( If /i " !background!"= " Default" set background=Black If " !background!"= " " set background=Black If /i " !foreground!"= " Default" set foreground=White If " !foreground!"= " " set foreground=White REM If you want to get a little fancy then you can also try REM - %ESC%[4m - Underline REM - %ESC%[7m - Inverse set foreground= % ~1 :: Defaults to "White" :: string background color name. :: Sets up the ESC string for use later in this scriptįor /F " tokens=1,2 delims=#" % %a in ( ' "prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (Įxit /B 0 :: Sets the currentColor global for the given foreground/background colors :: currentColor must be output to the terminal before outputing text in :: order to generate a colored output. ![]() REM Set to false if you find your environment just doesn't handle colors well set useColor=true ![]() The format of the string for foreground color is: The following table lists the codes ColorĪnd the reset code is ESC[0m where ESC is the escape code. To output colored text you need to echo the control characters for the required color, then output your text, and then (to be tidy) reset the output back to defaults. ![]() This is a companion article to How to change text color in a Linux terminal Terminal colors ![]() For instance you may want an error to appear in red, success in green, or important info to be output in bold.Īdding color to your terminal output is straightforward and involves outputting the correct control characters before your text. The default text output to a terminal is monochromatic and doesn't provide a simple method to provide context.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |