How to display files in different colors?

Sdir displays files in color by default. The colors chosen can be configured via environment variables or the command line. By default, colors are chosen from the file extension and file attributes, but all of the metadata that Sdir supports can be used to evaluate and determine which colors to use. Metadata can be evaluated using common operators, including equality, greater than, less than, and more.

Because Sdir already includes built in rules for determining file color, and it is often convenient to add a rule and leave existing rules in place, Sdir supports three different environment variables:

These are color rules that will be processed before any rules built in to Sdir.
These rules discard the built in rules, and replace them with an entirely custom configuration.
These rules are evaluated after processing any built in rules.

Each rule consists of a file attribute to check, an operator to check it with, and a result to apply if the condition is true. So, a rule making all files ending in .html red and all files ending in .js green would be "fe=html,red;fe=js,green". Multiple colors can be combined with "+", so allowing colors and keywords or background and foreground colors to be specified.

Screenshot of sdir

File attributes

A list of file attribute values and meanings is available here.


File attribute is equal to criteria
File attribute is not equal to criteria
File attribute is greater than criteria
File attribute is greater than or equal to criteria
File attribute is less than criteria
File attribute is less than or equal to criteria
File attribute includes criteria or wildcard string
File attribute does not include criteria or wildcard string

Supported colors

   black            darkgray         bg_black            bg_darkgray        
   blue             lightblue        bg_blue             bg_lightblue       
   green            lightgreen       bg_green            bg_lightgreen      
   cyan             lightcyan        bg_cyan             bg_lightcyan       
   red              lightred         bg_red              bg_lightred        
   magenta          lightmagenta     bg_magenta          bg_lightmagenta    
   brown            yellow           bg_brown            bg_yellow          
 white            bg_gray             bg_white           


The bright form of the color should be used.
The object should not be displayed.
The background and foreground color should be swapped.
After having made a rule match, continue looking for subsequent matches.