Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Directories with a Bold Font – How to enable? with .bash_profile? [closed]

Tags:

linux

bash

unix

I'm using a linux server that display directories in a bold font, and files in a normal font.


e.g. $ ls produces

afile.txt afolder anotherfile.txt anotherfolder


I'd like to use this feature on some other servers. How can it be done? with the .bash_profile?

If anyone has other ideas on how to differentiate folders from file, they'd be good to know?

like image 323
Ross Avatar asked Apr 10 '10 14:04

Ross


2 Answers

You need to give ls the --colors=… option (e.g. via an alias). To actually configure the LS_COLORS environmental variable used to define the colours, one good way is to create a configuration file for dircolors, e.g. with just bold (attribute 1) directories:

echo DIR 1 >~/.dir_colors

Then in your .bash_profile or .bashrc, eval the output of dircolors run on that file to set LS_COLORS according to your configuration. The relevant lines in my .bashrc (copied from somewhere) look like this:

  if [ -n "$COLORTERM" ]; then
      alias ls='ls -F --color=auto'
      if [ -x "`which dircolors`" -a -r "$HOME/.dir_colors" ]; then
          eval `dircolors -b "$HOME/.dir_colors"`
      fi
  else
      alias ls='ls -F'
  fi

Note that some terminals do not, by default, display the bold attribute as true bold but rather just use a brighter colour. You need to configure your terminal to get real bold.

See the dircolors --print-database for an example of a “complete” configuration file.

like image 168
Arkku Avatar answered Sep 20 '22 11:09

Arkku


add this to your .bashrc or .profile: alias ls='ls --color=auto'

like image 35
synkro Avatar answered Sep 22 '22 11:09

synkro