lscolors 0.5.0

Colorize paths using the LS_COLORS environment variable


Build Status Documentation

A library for colorizing paths according to the LS_COLORS environment variable (like ls).


use lscolors::{LsColors, Style};

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

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

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

Command-line application

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

> find . -maxdepth 2 | lscolors

> rg foo -l | lscolors

You can install it by running cargo install lscolors or by downloading one of the prebuilt binaries from the release page.


Licensed under either of

at your option.


Information about the LS_COLORS environment variable is sparse. Here is a short list of useful references: