당당한 프로그래밍

mac에서 iTerm2 디렉토리 및 파일 색상 변경하기

당당한하수 2021. 1. 5. 11:35

LSCOLORS 사용하기

".bashrc_profile" 수정을 통해서 색상 적용이 가능하다.

 

cd ~
vi .bash_profile

 

.bash_profile 안에서 아래와 같이 추가하면 된다.

 

export LSCOLORS="EHfxcxdxBxegecabagacad"
alias ls='ls -G'

 

첫 번째 라인의 LSCOLORS는 항목별 색상 정보를 나타내며, 총 22개의 캐릭터로 구성된다.

두 개의 캐릭터(Foreground, Background)가 한 개의 속성 색상을 의미한다.

속성과 색상 정보는 아래와 같다.

 

# 속성 정보
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

# 색상 정보
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

참고 사이트

 

두 번째 라인의 alias 부분은 ls라는 명령어를 커맨드 창에 입력했을 때, ls -G가 실행되도록 해준다.

ls 명령어에 G가 빠지면 적용이 되지 않던데, 그 이유는 정확히 파악을 하지 못했다.

 

source ~/.bash_profile

적용하는 부분을 잊어버리지 말자.

 

 

 

참고 사이트

 

 

'당당한 프로그래밍' 카테고리의 다른 글

파이썬 (Python) 한글 인코딩 해결하기  (0) 2021.01.05