LoginSignup
72
74

More than 5 years have passed since last update.

ls コマンドをカラーで

Posted at

ls の結果をカラー表示

Debian

  • ls --color=auto

ディレクトリが青色だと黒い画面で見づらい(Debian)

  • 色設定を一旦、ファイルに吐き出してディレクトリ部分を変更する
$ dircolors -p > ~/.colorrc
$ $EDITOR ~/.colorrc
  • 下記の 34 を 41 にすれば背景色赤になってディレクトリ判定しやすい
DIR 01;34 # directory

Mac

  • ls -G

ディレクトリが青色だと黒い画面で見づらい(Mac)

  • 先頭の1文字目がディレクトリ文字色、2文字目が背景色
  • 1文字目をx(無効)にして、2文字目をb(赤)に変更
$ export LSCOLORS=xbfxcxdxbxegedabagacad

.bashrc に反映しておく

  • uname コマンド使ってOS判定してもらえば個別管理しなくて済む
if [ "$(uname)" = 'Darwin' ]; then
    export LSCOLORS=xbfxcxdxbxegedabagacad
    alias ls='ls -G'
else
    eval `dircolors ~/.colorrc`
    alias ls='ls --color=auto'
fi

参考にしたサイト

72
74
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
72
74