Last Updated :
29 Nov, 2023
Color is an inbuilt command found inside the Windows Command Processor (cmd.exe), that is used for changing the colors of the console’s foreground and background. By default, the console has white foreground color and black background color (07 color code). The command is generally used either to personalize the aesthetics of the console window, or the make the colors more appropriate for Dim or Dark Displays (ex. TN panels). In this article, we will learn about the color command and will also take a look at the various uses it offers.
Description of the Command: Type the command – color /? in the Command Prompt. It sets the default console foreground and background colors.
COLOR [attr] attr - Specifies the color attribute of console output.
Color attributes are specified by two hex digits –
- First corresponds to the background.
- Second corresponds to the foreground.
Using the Command: The command takes in input 2 hexadecimal digits (2nd digit optional) where the first digit corresponds to the background color and the second digit corresponds to the foreground color.
Syntax:
Color (Background)(Foreground)
If the first digit is only provided, then only the foreground color changes. Each digit can have any of the values in hexadecimal codepoint (0 – f) where each one corresponds to a unique color. The digit-to-color correspondence is as follows –
0 = Black 8 = Gray 1 = Blue 9 = Light Blue 2 = Green A = Light Green 3 = Aqua B = Light Aqua 4 = Red C = Light Red 5 = Purple D = Light Purple 6 = Yellow E = Light Yellow 7 = White F = Bright White
Syntax:
Color 1F
It will produce bright White on Dark Blue. Any combination of the above set of digits could be used, except for the special case in which the foreground and the background color is the same (Ex. color FF or color 33). In that case, no color change occurs, and the value of %ERRORLEVEL% changes to 1. If the command is executed without providing any parameters, then the command will restore the color to which cmd.exe initially started as.
Changing Only The Foreground Color:
Syntax :
Color (Hex_digit)
- (Hex_digit) is a digit (or character) within the hexadecimal range, i.e. it should belong in the range 0-F. Example : We will change the foreground color to Yellow (6). Before :
After :
It is clear from the above images that after executing the command Color 6, the color of the foreground changes from white to yellow.
- Changing the Color of Background And Foreground: For changing the color of the foreground and the background of the console window, the color attributes are specified by 2 of the previously mentioned hex digits.
Syntax :
color (Back_Hex_digit)(Fore_hex_digit)
- Back_Hex_digit and Fore_hex_digit are hexadecimal digits used to determine the color of the background and foreground respectively. In the following example, we will change the background color to grey (7) and the foreground color to light green (a).
Before:
After:
Загрузить PDF
Загрузить PDF
Вам надоело постоянно видеть стандартный белый текст на черном фоне в командной строке? Если да, тогда читайте дальше, чтобы узнать, как изменить цвет текста и фона.
-
-
-
Введите color z, чтобы получить список всех цветов и цифры или буквы, которые им соответствуют. Первые буква/цифра — это цвет фона, а вторая — цвет текста.
-
Например, введите color 6, чтобы получился желтый текст, color 4 для красного цвета, color A для изменения текста в светло-зеленую окраску и так далее.
-
Для изменения цвета текста, а также его фона, введите color ce, чтобы получился светло-желтый текст на светло-красном фоне, или любую другую комбинацию. Первая буква/цифра обозначает цвет фона, а вторая соотносится с цветом текста.
Реклама
-
-
-
-
-
Выберите свойства текста или фона и отредактируйте цветовые значения.
- Поэкспериментируйте с различными комбинациями!
-
Реклама
Список возможных расцветок
- 0 = Черный
- 1 = Синий
- 2 = Зеленый
- 3 = Аквамарин
- 4 = Красный
- 5 = Фиолетовый
- 6 = Желтый
- 7 = Белый
- 8 = Серый
- 9 = Светло-голубой
- A = Светло-зеленый
- В = Светлый аквамарин
- С = Светло-красный
- D = Светло-фиолетовый
- E = Светло-желтый
- F = Ярко-белый
Советы
- Будьте осторожны в правописании слова «color» и не введите по ошибке «colour». В противном случае изменения не сработают.
Реклама
Об этой статье
Эту страницу просматривали 104 072 раза.
Была ли эта статья полезной?
How many of you agree that in spite of all the useful features that Command Prompt possesses, it seems to be a bit boring due to the white color font with a black background?
Windows has always been colorful. Be it themes, background, or the colorful icons. Don’t you think, your colorful Windows OS should stay colorful, irrespective of the program running on it ?
So, let’s add a dab of color to Command Prompt on Windows 10, 8, and 7 and make it look vivid.
There are two different methods to change Command Prompt’s background and font color for Windows 10, 8, and 7.
1. Use Commands
Before changing the font color, you can get an overview of what can be done with the color command. Follow these steps to change the font and background color:
- Go to Start button, type ‘CMD’ in the search box to open Command Prompt.
- Command Prompt window will open, type “color/?”
- You will get the color codes.
- To get the color of the background and font changed, use the color command option along with the background color code followed by the font color code.
For Example: Let’s paint Command Prompt in white background with red font color.
- Type “Color 74”
- To change it back to default white font and black background, type “color” and boom, everything is back to basics.
- Now, you can try different combinations to make the dull command prompt window look cooler.
2. Make Changes in Properties
Don’t want to enter any commands, still, want to play with the color and customize Command Prompt. Follow these steps:
If you have Windows 10 installed, you can adjust transparency as well. Under all the different sections on Colors tab, there is an option Opacity. You can set the transparency of Command Prompt to the desired level.
Also Read: How To Remove Computer Virus Using CMD
Note: This option is only available if you have unchecked the Use legacy console setting from the Options tab.
These are the two different methods to make your Command Prompt look as colorful and vibrant as you want. Try them and let us know, which one worked for you.
Watch Video to Know More.
С наступающим, коллеги. Все знают, что для консоли в windows можно легко задать цвет текста и фона. Но мало кто знает, что остальные 14 цветов тоже можно задать, существенно упростив себе работу с консольными приложениями, поддерживающими цвета в windows — например, git или mercurial. Под катом я в лицах и картинках расскажу о своей борьбе с цветами и о получившейся в результате утилитке на python, которая позволяет раскрасить консоль одной командой, дабы больше не видеть этого бело-синего ужаса powershell.
ANSI Colors
Итак, я хочу поменять все цвета в консоли, а не только текста и фона. Для начала посмотрим, что это за цвета. В linux и osx все просто — есть стандарт «ANSI Colors», который гласит, что если вывести в консоль определенную последовательность символов, то следующий за ней текст будет покрашен во все цвета радуги:
К сожалению, авторы windows данный стандарт не поддержали, но нечто похожее имеется — 16 цветов, которыми можно раскрашивать текст и фон. Простенькая программа на python показывает, как это выглядит:
from ctypes import *
windll.Kernel32.GetStdHandle.restype = c_ulong
h = windll.Kernel32.GetStdHandle(c_ulong(0xfffffff5))
for color in xrange(16):
windll.Kernel32.SetConsoleTextAttribute(h, color)
print "color {0}".format( color )
Цвета, мягко выражаясь, печальные. Особенно если сравнивать результаты с цветовой схемой по умолчанию в ubuntu:
Меняем цвета
Цветовые настройки консоли хранятся, что ожидаемо, в реестра. Нас интересует ключ HKEY_CURRENT_USER\Console, значения от «ColorTable00 (черный, он же цвет фона) до ColorTable15 (яркий белый). Значения: DWORD, 0x00BBGGRR. Меняем эти волшебные ключи и получаем то же самое, что и в Ubuntu. Единственная разница — цвета идут в другом порядке:
Цель достигнута? Похоже на то. Но тут есть…
Интрига
Радуемся новым цветам. Через некоторое время понимаем, что у нас Windows 7 или Windows 8 и мы хотим прикрепить консоль в taskbar, дабы вызывать ее через хоткей „win+номер“. Делаем „pin this program to taskbar“, запускаем, и видим ЭТО:
Откуда взялся этот синий фон, который при раскраске становится черным? Ведь если запустить консоль через „win+r“ — мы видим наши цвета, установленные на предыдущем шаге. Тут кроется самое интересное — когда мы прикрепляем консольное приложение на taskbar, Windows создает для него ярлык (файл с расширением .lnk) и устанавливает для этого ярлыка персональные настройки цветов. Что делать? Берем в руки python, немного COM, и модифицируем настройки ярлыка. Теперь совсем все работает.
Обещанные два клика
Чтобы не растерять квалификацию программиста, я оформил все вышеперечисленное в качестве небольшого модуля на python, который можно использовать в качестве утилиты командной строки. Если у вас уже установлен python, то для установки моего шедевра достаточно выполнить команду:
pip install pywincmdtheme
Если же python у вас не стоит, то рекомендую поставить сборку ActivePython — кроме python она содержит еще и ряд предустановленных расширений, полезных для работы под Windows. Как с помощью утилиты раскрасить консоль под хохлому? Если запустить утилиту без аргументов командной строки, то она попытается найти в директории пользователя файл .Xresources и применить цвета из него. Если же такого файла нет, то будут применены цвета из ubuntu, которые я демонстрировал в примерах выше. Файл .Xresources — это штатный для *nix способ хранения настроек терминала, в частности цветовых схем. Если погуглить, то можно найти красивые готовые схемы.
Работа с ярлыками чуть сложнее — чтобы модифицировать настройки ярлыка, необходимо вызвать утилиту с ключом командной строки ‘—update-link’ и полным путем к ярлыку. Ярлыки прикрепленных на taskbar программ в Windows хранятся в директории „%USERPROFILE%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar“. Пример модификации ярлыка powershell, прикрепленного к taskbar:
pywincmdtheme --update-link "%USERPROFILE%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Windows PowerShell.lnk"
Вроде все. Еще раз с наступающим всех, надеюсь кому-нибудь вышеизложенное пригодится :).
Если эта публикация вас вдохновила и вы хотите поддержать автора — не стесняйтесь нажать на кнопку
The Windows Command Prompt is a tool most of us rarely use these days, and when we do it can be a bit boring — not to mention eye-straining — to use while staring at the default white text on a black background.
However, many people still don’t know that it’s easy to customize the look of the Windows Command Prompt with different colors and fonts. This can make it feel a bit more personal, and help you have a bit more fun while using the Command Prompt to do things like check your laptop’s battery life or find your Windows 10 product key.
- How to watch Star Wars in ASCII on Windows 10
- How to create a Kill Switch in Windows
- How to type an em dash in Windows and macOS
So if you’re ready to stop staring at that boring black-and-white text box, read on to find out how you can customize your Command Prompt’s color scheme.
How to change Command Prompt color in Windows 10
1. Obviously, the first thing to do is fire up the Windows Command Prompt. In Windows 10, the quickest way to accomplish that is to hit the Start button and type «cmd» — you should see the Command Prompt app highlighted as the top search result. Go ahead and open it.
If that doesn’t work, you can manually scroll down the Start Menu’s app list and find Command Prompt under the Windows System section. Click the Command Prompt app to launch it.
2. Once the Command Prompt is running you should find yourself staring at a familiar black window with white text spelling out a command line — likely starting with C: and ending with your Windows user name. We’re going to use the color command to change things up, and you can get a sense of the possibilities by typing color /? and hitting Enter.
As you can see, the color command is pretty self-explanatory: you can use it in combination with the provided table of colors corresponding to alphanumeric characters to set the color of the Command Prompt text and background by typing color XY, where X is the alphanumeric character of the color you want the text to be and Y is the background color you want.
Get instant access to breaking news, the hottest reviews, great deals and helpful tips.
You can also see that the color command will throw an error if you try to set the foreground and background to the same color, which means you can’t accidentally render the Command Prompt unusable with this command. Let’s give it a spin, eh?
3. To see how it works, let’s pull a Matrix and set the Command Prompt to use bright green text on a black background. To do so, you type color 0a and hit Enter.
I like to use bright text colors on a black background for optimal comfort, but if you prefer something a bit less stark, you could also try a bright color on gray. To test out light aqua on gray, for example, type color 8b.
4. If you tire of your custom color scheme and want to return your Command Prompt back to its default white-on-black, all you have to do is type color and hit Enter to reset everything to factory standard.
Also, it’s important to note that all changes with the color command are temporary. Once you close the Command Prompt, they’ll be forgotten, and when you open it again it will be back to its default white-on-black look.
5. To permanently change the Command Prompt color scheme, we need to get into the Command Prompt’s Properties menu. The easiest way to do this is to right-click the Command Prompt window while it’s running, then select Properties from the menu which pops up.
In the Properties menu you’ll find a smorgasbord of options for customizing the look of your Command Prompt: you can set different fonts, colors, and text sizes, change the way the Command Prompt cursor looks, set the default window size, change its opacity, and more.
What’s more, all of these changes are permanent when made through the Properties menu. That means if you give your Command Prompt a cleaner font, some sharper colors, and a 60% opacity level so you can still see what you’re working on behind the Command Prompt window, all of those changes will still be in effect after you close it and launch it again days later.
And if you type color to reset your Command Prompt’s color scheme, it will reset back to whatever you’ve configured in the Properties menu, rather than back to the default white-on-black —so if you want to undo your changes, you need to do so manually in the Properties menu.
More tips from Tom’s Guide
- How to turn off automatic updates in Windows 10
- How to check your PC’s CPU temperature
- How to enable God Mode in Windows 10 and 11
- How to use System Restore in Windows 10
- How to disable the Windows key in Windows 10
- How to use Enhanced Search Mode in Windows 10
Alex Wawro is a lifelong tech and games enthusiast with more than a decade of experience covering both for outlets like Game Developer, Black Hat, and PC World magazine. A lifelong PC builder, he currently serves as a senior editor at Tom’s Guide covering all things computing, from laptops and desktops to keyboards and mice.