LoginSignup
13
14

More than 3 years have passed since last update.

【Bash】lsしたときの色を変更する

Last updated at Posted at 2019-04-26

キーワード:ls, Terminal, Color, bash, Linux

以下のページを参考に,Terminalでlsした時に
ディレクトリが太字でかつ自分好みの色で表示されるよう設定しました.
http://neko-mac.blogspot.com/2015/03/mac_18.html

今回一番重要なのはここ

.bash_profile
export LSCOLORS=Cxfxcxdxbxegedabagacad

 
COLORS=の後ろのわけわかめな文字列だ

ここの一番左のアルファベットがlsした時のディレクトリの色と太さを決める

僕が参考にした時はここがe(ただのシアン)になっていたので

ここをC(太字のグリーン)に変更した.

今回の目的はとりあえずディレクトリを参照した時の色付けだけだったのでこれだけです

念のため僕の.bash_profile載せときます

.bash_profile
# ls した時の色付け
alias ls='ls -G'
export LSCOLORS=Cxfxcxdxbxegedabagacad

#ターミナル起動するたびに毎回 source ~/.bash_profile するの面倒なので自動でさせる
if [ -f ~/.bashrc ] ; then
. ~/.bashrc
fi

これで大丈夫です

こんな感じでいい感じに色付けされました!

Screen Shot 2019-04-26 at 12.20.43.png

また,実行可能な実行ファイルはlsした時に赤色になります

Screen Shot 2019-04-26 at 14.00.22.png

あ!ちなみに,

.bash_profile

$ vi ~/.bash_profile

で編集

$ source ~/.bash_profile

で変更を反映

できます

ありがとうございました( ・∇・)

13
14
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
13
14