Colors of ls

  • Use of colors for indicating different types of files and directories can be enabled for the ls command. This is useful to discern the files you want from the output quickly.

  • To enable color output use the --color option. To be more clever and show colors only when the output is not being piped to another program, use the --color=auto option.

  • By default, these colors are used: blue for directories, cyan for symbolic links, green for executables, yellow for device files, red for archived files and pink for image files.

  • You can see the color settings for the various file types and extensions by running the dircolors command or echo $LS_COLORS. Both of them should show the same output.

  • The explanation of the various foreground and background color values as set in $LS_COLORS are explained here.

  • To set your own colors or add new filetypes with colors, change the $LS_COLORS environment variable in your shell startup file.

  • Once you have colors, you may find the character indicators that ls uses by default as unnecessary. You can turn them off by using the --indicator-style=file-type option.

Console2: Change Text Color

Console2 is a Windows utility that can be used to host the Windows command shell (cmd.exe), PowerShell, Cygwin shells or any other shell. By default, it displays a black background and the text is displayed in a dull gray color.

The Settings dialog of Console2 does not really indicate where this text color comes from or how to change it. To change the default text color to pure white or any other color, open EditSettings dialog. In the Console Colors Map section, locate the gray color square (marked in the screenshot above) and change it to any color you want. The console text will be displayed in your chosen color.

Tried with: Console2 2.00.147

Colors in the Windows Command Prompt

The main color settings of the Windows command prompt that can be changed are the background and text (foreground) color. There is also the equivalent popup background and text color, but that is rarely used.

Colors Dialog

The most common way to change the colors is to open the window menu (click the top left corner of window or press Alt+Space) and choose Properties and pick the Colors tab in the Properties dialog. There are 16 pre-defined colors available for the background and text. To set a custom RGB value as the background or text color, click on one of the pre-defined color squares and then set that square’s custom color by using the Selected Color Values section in the top right corner.

Color Command

Sometimes, you might be stuck at the command prompt of a friend who has set colors that are making your eyes bleed! 😀 Use the color command from the command-line to change the color for that session temporarily and save your eyes! For example to switch to a black-on-white color setting immediately, type color F0 at the prompt.

The color command accepts one value of type XY, where X and Y are hexadecimal digits. X represents the background and Y the text color. Each of those values is one of the 16 pre-defined (or customized) colors set for that command-prompt using the Colors dialog (as described above). If the same value is provided for both background and text (00 for example), it is ignored.

After finishing your work at the friend’s command prompt, you can switch back to his painful colors by typing color (with no arguments).