lsコマンドを入力するとディレクトリ名が読みにくい
最近、CentOS7を使ってサーバー構築などの勉強をしているのですが、ls
でディレクトリを表示した時がまー見にくいです。
黒の背景に青文字って……
まともに読もうとしたらマジで目が死にます。
なので、それを変える方法を今回は投稿します。
手順
$ su
# cd /etc
# cp -p DIR_COROLS DIR_COROLS_org //念のためバックアップファイル作成
# vi DIR_COROLS
以下の部分を/DIR
などと入力して見つけて、編集します。
(前略)
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 01;36# symbolic link
FIFO 40;33# pipe
SOCK 01;35# socket
BLK 40;33;01# block device driver
CHR 40;33;01# character device driver
ORPHAN 01;05;37;41# orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to
(後略)
エスケープ文のところに丁寧に書かれてるのでそれを読むのが一番ですが、簡潔に言うと
Attribute codes
が文字の属性(太字・アンダーラインなど)、
Text color codes
が文字色、
Background color codes
が背景色となります。
あとは説明されてる通りにコードを編集すれば、大丈夫です。
私は太字をやめて背景を白にしたかったので、DIR 00;34;47
としました。
↓こんな感じです。
その後に下記コマンドを入力して、ログアウトしてください。
(ログアウト忘れたせいで表示が変わらず、無駄にハマりました…)
# eval 'dircolors /etc/DIR_COLORS -b' //実行結果が出力されます
# exit
$ exit
ちなみに
Macでは.bashrc
に以下を記載すると良い感じになります
.bashrc
alias ls='ls -FG'
export LSCOLORS=gxfxcxdxbxegedabagacad
# 上記を記載後ターミナルで↓
$ source ~/.bashrc