LoginSignup
46
41

More than 5 years have passed since last update.

lsコマンドの色を変更する

Posted at

lsコマンドで表示されるディレクトリの文字色が青だと見辛い時があります。
そんな時に変更する方法を紹介します。

linuxでの変更方法

  1. ターミナルの色に関するファイルを取得 dircolors -p > ~/.colorrc
  2. .colorrcの中の, ディレクトリの色を指定しているところを変更
  3. 変更した~/.colorrcをlsの時に反映されるように~/.bashrcに追記
  • ディレクトリの色を指定しているところはこんな感じになってます。
.colorrc
### 中略 ###

RESET 0 # reset to "normal" color
DIR 01;34 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)

### 中略 ###
  • .bashrcに追記する内容は以下です
.bashrc
eval `dircolors ~/.colorrc`
alias ls='ls --color=auto'

色と番号の対応は下の表のようになってます。

番号
30
31
32
33
34
35
36
37

https://www.gfd-dennou.org/arch/morikawa/memo/ls_colors.txt

macで変更する場合

LSCOLORSという環境変数に色のパラメータを指定してあげます。

config.fish
set -x LSCOLORS  exfxcxdxbxegedabagacad
.bashrc
export LSCOLORS=exfxcxdxbxegedabagacad
alias ls='ls -G'

一番先頭(例ではex)がディレクトリの文字色を設定するパラメータです。
色とパラメータの対応は下の表のようになってます。

パラメータ
a
b
c
d
e
f マゼンタ
g シアン
h 明い灰

ls の結果に色をつける - ねもぷらす

46
41
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
46
41