Customizing the colors for ls

The command line tool ls can be configured to use different colors for different file types, e.g. blue directories or red archive files. To use the predefined color scheme just activate this feature in your personal settings. For the Bourne Again Shell (bash) edit the file ~/.bashrc with your favourite editor and add (or uncomment) the following lines:
eval `dircolors -b`
alias ls='ls --color=auto'

If you don't like the predefined colours, you can change the configuration to achieve an esthetically pleasing impression.
  1. Create your personal configuration file with a command like:
    dircolors --print-database > ~/.dircolorsrc
    Notice that the file name is only an example, feel free to choose another name.
  2. Add the path name of your new configuration file to your personal settings in the file ~/.bashrc like this:
    eval `dircolors -b ~/.dircolorsrc`
  3. Edit ~/.dircolorsrc to customize the appearance of different files, one line per type. The content of the configuration file is quite self-explanatory:
    • Show flac files in cyan with:
      .flac 36
    • Display orphaned symbolic links underlined and blinking (this is pretty pesky) with:
      ORPHAN 04;05
  4. To test your settings you can reread the personal configuration with:
    source ~/.bashrc (or even shorter with: . ~/.bashrc)

-- StefanHaller - 18 Feb 2008
Topic revision: r1 - 2008-02-18, StefanHaller
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback | Legal notice | Privacy Policy (german)