Announcing lscolors: colorize paths according to the LS_COLORS environment variable


I have recently extracted the ls-like path colorization from my fd tool into a separate crate because I felt that it might be useful for other CLI tools as well. The new crate is called lscolors. You can find more information here:

Docs on

The crate can be used like this:

use lscolors::{LsColors, Style};

let lscolors = LsColors::from_env().unwrap_or_default();

let path = "some/folder/";
let style = lscolors.style_for_path(path);

// If you want to use `ansi_term`:
let ansi_style =;
println!("{}", ansi_style.paint(path));

This crate also comes with a small command-line program called lscolors that can be used to colorize the output of other commands, for example:

> find . -maxdepth 2 | lscolors

> rg foo -l | lscolors