tags:

views:

38

answers:

2

Hello,

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?

+1  A: 

It's done with an environment variable. Start with reading the ls man page:

$ man ls

You may not be able to get just bold, but only bold with a specific color.

Paul Beckingham
+2  A: 

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.

Arkku