dir_colors - Linux


Overview

dir_colors is a powerful command-line utility that enhances the appearance of directories and files in a terminal. It enables users to customize the colors assigned to different file types, directories, and symbolic links, improving visual clarity and organization.

Syntax

dir_colors [--colors-from file] [--theme theme] [--reset] [--install]

Options/Flags

  • –colors-from file: Loads a custom color scheme from a specified file.
  • –theme theme: Selects a predefined color theme to apply.
  • –reset: Resets the color settings to the default scheme.
  • –install: Installs the current color scheme globally for all users.

Examples

Basic Usage – Apply a Custom Color Scheme:

dir_colors --colors-from my-colors.scheme

Set the Solarized Dark Color Theme:

dir_colors --theme=solarized

Resetting to Default Colors:

dir_colors --reset

Installing a Global Color Scheme:

dir_colors --install

Common Issues

Missing Color Scheme:

If a custom color scheme file is not found or is incorrectly formatted, dir_colors will not apply the scheme.

Resetting Colors After Installation:

Once a color scheme is installed globally, it can only be reset by manually editing the configuration files in /etc/DIR_COLORS or via the --reset option.

Integration

Linking to ls Alias:

To permanently apply a color scheme to the ls command, create an alias in your shell configuration file:

alias ls="dir_colors --theme=solarized && ls -F"

Use with Find:

Combine with find to highlight specific files or directories:

find . -name "*test*" | dir_colors --colors-from my-colors.scheme

Related Commands

  • ls – List files and directories.
  • find – Find files and directories based on criteria.
  • exa – A modern alternative to ls with advanced customization options.