명령줄 터미널의 ANSI 색상을 구성하는 방법

명령줄 터미널의 ANSI 색상을 구성하는 방법

나는 특히 Mac OS X에서 bash를 사용하지만 대답은 Unix-generic이 될 것이라고 생각합니다.

이미 ANSI 색상을 사용하고 있는데 폴더, 숨김 파일 등에 다른 색상을 다시 지정하고 싶습니다.

업데이트: 숨겨진 파일에 특정 색상을 할당할 수 없고 고정된 권한 비트 색상이 디렉토리보다 우선하기 때문에 디렉토리를 항상 같은 색상으로 지정할 수 없기 때문에 이것은 예상만큼 유용하지 않았습니다(올리브 녹색). 스크린샷에서)

답변1

~/.profile을 다음과 같이 수정하세요. 이미 가지고 있고 사용하는 것에 따라 ~/.bashrc 또는 ~/.bash_profile에 이를 넣을 수도 있습니다. 참고: 이는 기본 색상 설정을 보여줍니다. 빨간색 디렉터리를 보려면 첫 번째 e를 B로 변경하세요.

    LSCOLORS=exfxcxdxbxegedabagacad

    export LSCOLORS

    export CLICOLOR=1    

~/.profile을 저장하고 다음을 수행하십시오.

    . .profile

명령줄에서.

ls 매뉴얼 페이지의 다양한 색상 설정 및 속성 순서는 다음과 같습니다.

LSCOLORS        The value of this variable describes what color to use for which attribute when colors are enabled with CLICOLOR.  This string is a
                 concatenation of pairs of the format fb, where f is the foreground color and b is the background color.
                 The color designators are as follows:

                       a     black
                       b     red
                       c     green
                       d     brown
                       e     blue
                       f     magenta
                       g     cyan
                       h     light grey
                       A     bold black, usually shows up as dark grey
                       B     bold red
                       C     bold green
                       D     bold brown, usually shows up as yellow
                       E     bold blue
                       F     bold magenta
                       G     bold cyan
                       H     bold light grey; looks like bright white
                       x     default foreground or background

                 Note that the above are standard ANSI colors.  The actual display may differ depending on the color capabilities of the terminal in
                 use.

                 The order of the attributes are as follows:

                       1.   directory
                       2.   symbolic link
                       3.   socket
                       4.   pipe
                       5.   executable
                       6.   block special
                       7.   character special
                       8.   executable with setuid bit set
                       9.   executable with setgid bit set
                       10.  directory writable to others, with sticky bit
                       11.  directory writable to others, without sticky bit

                 The default is "exfxcxdxbxegedabagacad", i.e. blue foreground and default background for regular directories, black foreground and red
                 background for setuid executables, etc.

답변2

dircolors(1) 명령을 사용하면 쉘 시작 스크립트에서 평가할 수 있는 명령을 생성하여 /bin/ls에 출력 색상 지정 방법을 알려주는 환경 변수 LS_COLORS를 설정할 수 있습니다. 자세한 내용은 다음에서 확인할 수 있습니다.http://linux.die.net/man/5/dir_colors.

관련 정보