ls や出力色を変える
ファイルを生成
色を変えるためのファイルを出力します。
dircolors -p > ~/.dircolors
nano ~/.dircolors # 好みの色に編集
このファイルは、LinuxのUbuntuでは下記のように~/.dircolorsがあれば読み込むようになっている。
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
基本色コード(文字色)
コード | 色 | 説明 |
---|---|---|
30 | 黒 | Black |
31 | 赤 | Red |
32 | 緑 | Green |
33 | 黄 | Yellow |
34 | 青 | Blue |
35 | マゼンタ | Magenta(紫) |
36 | シアン | Cyan(水色) |
37 | 白 | White(灰色っぽい) |
明るい色(90~97)
コード | 色 | 説明 |
---|---|---|
90 | 明るい黒(グレー) | Bright Black / Gray |
91 | 明るい赤 | Bright Red |
92 | 明るい緑 | Bright Green |
93 | 明るい黄 | Bright Yellow |
94 | 明るい青 | Bright Blue |
95 | 明るいマゼンタ | Bright Magenta |
96 | 明るいシアン | Bright Cyan |
97 | 明るい白 | Bright White |
実用例
- ディレクトリを太字白文字+青背景:
DIR 01;37;44
- 実行ファイルを太字黒文字+緑背景:
EXEC 01;30;42
- 圧縮ファイルを太字白文字+赤背景:
*.tar 01;37;41
*.zip 01;37;41
*.gz 01;37;41