Skip to content

[Linux] How to Change File Color in Terminal

Recently, I have been studying how to change the visual effects in my Linux operating system. Thanks to this, I will record how to change the file color in terminal today.

If you want to change folder color in the graphical interface, you can refer: [Linux] Use "folder-color" to change the color of Nautilus folder

Back to the topic, the default file in terminal just looked like:

Of course we can change the color for them.


Use dircolors to change color

In Linux, we can use dircolors to check current configuration.

dircolors -p > .dircolors 
vim .dircolors

And we can see some color settings in the .dircolors file.

DIR 01;34

In VIM editor, you can use Esc + "/DIR" to find this pattern. In here, 01 is means Bold and 34 is means blue. These settings need to be used ; separate

The parameters that can be set are as follows:

 0     to restore default color
 1     for brighter colors
 4     for underlined text
 5     for flashing text
30     for black foreground
31     for red foreground
32     for green foreground
33     for yellow (or brown) foreground
34     for blue foreground
35     for purple foreground
36     for cyan foreground
37     for white (or gray) foreground
40     for black background
41     for red background
42     for green background
43     for yellow (or brown) background
44     for blue background
45     for purple background
46     for cyan background
47     for white (or gray) background

Detailed instructions can refer to: https://linux.die.net/man/5/dir_colors


DEMO

For example, I chose a color template: https://linux.die.net/man/5/dir_colors

DIR 33;01;03;04

According to the instructions above, 33 is yellow-brown, 01 is basically bold, 03 is italic (the description above is missing), and 04 is the bottom line-so my folder display will be very special.

Save and leave, use the following command to reset the terminal:

bash

Very weird! I already want to change it.

Tags:

Leave a Reply