So I know that there is a way to change the color of text for directories, regular files, bash scripts, etc. Is there a way to change the color to the file based on the _file extension_
?
Example:
$ ls -l
foo.txt [is red]
foo.text [is blue]
foo.secret [is green]
foo.txt [is red]
Yes, using the LS_COLORS
variable (assuming GNU ls
). The easiest way to manipulate that is to use dircolors
:
dircolors --print-database > dircolors.txt
will dump the current settings to dircolors.txt
, which you can then edit; once you've added your settings,
eval $(dircolors dircolors.txt)
will update LS_COLORS
and export it. You should add that to your shell startup script.
To apply the example settings you give, the entries to add to dircolors.txt
would be
.txt 00;31
.text 00;34
.secret 00;32
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다