참으로 깔끔하게 잘 정리해놨네. Redhat 계열인 Fedora 나 CentOS 같은 경우는 /etc/DIR_COLORS 스크립트가 있지만, ubuntu 는 그런게 없네. 조금 특이한 방법이기는 하나, 아래와 같이 해서 잘 사용할 수 있다.

You ever fire up an xterm and perform an "ls" command? Sure you have! If so, did you ever wish that:
NOTE: All commands to be entered in a terminal shell or changes made to a file are hilighted in red. You only need to cut/paste those items which are hilighted, the surrounding text is left for illustration purposes.
1. Edit the '.bashrc' file. You need to make a few small changes to the existing bash script.
3. Edit the '.dircolors' file. Here is where you will be modifying/creating new color schemes to reflect your own unique style.
NOTE: Lines 34-41 within this file give you the color codes for three specific keys: attribute, text, and background. You can choose to use all three keys, or simply pick and choose only those keys you wish to apply. Look at some of the pre-defined ones you may already recognize as a good example to follow.
** END of Howto **
and, just to see your handy work, look at these two environmental variables:
NOTE: These color changes will be preserved upon each reboot or login. If you wish to revert to the original color scheme, just delete the file '.dircolors' in your $HOME directory (or, alternatively, restore your backup file made in step 1.i).
NOTE: I've only tested this with a plain 'ole vanilla stock 'xterm'. I do not use gnome-terminal, kterm(?), or any other variants but it should work equally well with them. I do not use any file managers of any sort, so without some MIME associated icon staring me in the face, these colors really help. Using 'dircolors' is old as dirt, and I'm surprised no one else hadn't mentioned this yet. Am I the only one who thinks CLI+color > [insert favorite File Manager here]? Surely, I'm not alone. Or am I...
\\//_
- certain files would "stand out" with a custom color, and not the defaults?
- you can add other filename extensions to the database with their own custom color as well?
NOTE: All commands to be entered in a terminal shell or changes made to a file are hilighted in red. You only need to cut/paste those items which are hilighted, the surrounding text is left for illustration purposes.
1. Edit the '.bashrc' file. You need to make a few small changes to the existing bash script.
- (optional) Backup the file. Copy your existing '.bashrc' file in case you wish to restore it at a latter time. For example,
Code:skoal@morpheus:///tmp $ cd && cp .bashrc .bashrc~ skoal@morpheus://~ $ ls .bashrc* .bashrc .bashrc~
- Modify the file. Using your favorite text editor, open the file '~/.bashrc' and make the following changes hilighted in red (which should appear somewhere near the top of that file - line 17 if no prior alterations were made). You will basically be modifying one line and adding two more above it.
Code:skoal@morpheus:///tmp $ gedit ~/.bashrc
Code:# enable color support of ls and also add handy aliases if [ "$TERM" != "dumb" ]; then [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors" [ -e "$DIR_COLORS" ] || DIR_COLORS="" eval "`dircolors -b $DIR_COLORS`" alias ls='ls --color=auto' #alias dir='ls --color=auto --format=vertical' #alias vdir='ls --color=auto --format=long' fi
- (alternative to step 1.ii) Patch the file. Using the attched 'bashrc.patch' file, patch the current '~/.bashrc' file instead of cutting/pasting with an editor.
Code:skoal@morpheus:///tmp $ bunzip2 bashrc.patch.bz2 skoal@morpheus:///tmp $ cp bashrc.patch ~ skoal@morpheus:///tmp $ cd && patch -p0 < bashrc.patch patching file .bashrc Hunk #1 succeeded at 19 (offset 5 lines).
Code:
skoal@morpheus:///tmp $ cd && dircolors -p > .dircolors
NOTE: Lines 34-41 within this file give you the color codes for three specific keys: attribute, text, and background. You can choose to use all three keys, or simply pick and choose only those keys you wish to apply. Look at some of the pre-defined ones you may already recognize as a good example to follow.
- Modify existing color schemes. For example, I can't stand big bold blue directory listings, so I change the bold attribute from "01" to "00" (none) but keep the blue color. It will lighten things up a bit.
Code:FILE 00 # normal file DIR 00;34 # directory LINK 01;36 # symbolic link.
Code:.gz 01;31 .bz2 01;31 .deb 07;31 .rpm 01;31 .jar 01;31
- Create new color schemes. I like to program, yet for some reason, there are no default colors for well known language extensions. I like my c/c++ source to show up as green and my header files as yellow. Here's how I added these extensions to the bottom of that file:
Code:# audio formats .ogg 01;35 .mp3 01;35 .wav 01;35 # programming languages .c 00;32 .cc 00;32 .cpp 00;32 .h 00;33
Code:
skoal@morpheus:///tmp $ cd && . .bashrc
and, just to see your handy work, look at these two environmental variables:
Code:
skoal@morpheus://~ $ set | grep 'DIR_COLORS\|LS_COLORS' DIR_COLORS=/home/skoal/.dircolors LS_COLORS='no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.c=00;32:*.cc=00;32:*.cpp=00;32:*.h=00;33:'
Code:
skoal@morpheus:///tmp $ rm -f ~/.dircolors
\\//_
Last edited by skoal; June 13th, 2005 at 09:28 PM..
반응형
'Software Development > OS 및 Container' 카테고리의 다른 글
[UNIX] 파일 찾기 관련 유틸들 (0) | 2010.03.08 |
---|---|
[UNIX] 현재 시스템이 32bit 인지 64bit 인지 보는 방법 (0) | 2010.02.17 |
[Windows] Windows 에서 Symbolic Link 만드는 방법 (0) | 2010.02.10 |
Ubuntu 에서 ntsysv 같은 유틸 (0) | 2010.02.03 |
Ubuntu 에서 hostname 변경하기 (0) | 2010.02.03 |