#cli #linux #terminal #filesystem #color

bin+lib lscolors

Colorize paths using the LS_COLORS environment variable

9 releases (breaking)

0.7.1 Jun 15, 2020
0.7.0 Apr 1, 2020
0.6.0 Sep 15, 2019
0.5.0 Jan 22, 2019
0.1.0 Dec 9, 2018

#25 in Command-line interface

Download history 1163/week @ 2021-02-26 1823/week @ 2021-03-05 1991/week @ 2021-03-12 2642/week @ 2021-03-19 2177/week @ 2021-03-26 1953/week @ 2021-04-02 1533/week @ 2021-04-09 1454/week @ 2021-04-16 5037/week @ 2021-04-23 5788/week @ 2021-04-30 4844/week @ 2021-05-07 3863/week @ 2021-05-14 7676/week @ 2021-05-21 7968/week @ 2021-05-28 9793/week @ 2021-06-04 6921/week @ 2021-06-11

11,238 downloads per month
Used in less than 8 crates

MIT/Apache

40KB
827 lines

lscolors

Build Status Crates.io Documentation

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

Usage

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 = style.map(Style::to_ansi_term_style)
                      .unwrap_or_default();
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.

License

Licensed under either of

at your option.

References

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

Dependencies

~92KB