sharkdp/lscolors


A Rust library to colorize paths using LS_COLORS

License: Other

Language: Rust

Keywords: ansi-colors, command-line, filesystem, ls-colors, rust, shell, terminal


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:

Project Statistics

Sourcerank 8
Repository Size 57.6 KB
Stars 57
Forks 2
Watchers 4
Open issues 4
Dependencies 1
Contributors 2
Tags 7
Created
Last updated
Last pushed

Top Contributors See all

David Peter Sylvestre Ledru

Packages Referencing this Repo

lscolors
Colorize paths using the LS_COLORS environment variable
Latest release 0.6.0 - Updated - 57 stars
logscroll
Provide a limited window for logs
Latest release 0.2.4 - Updated - 57 stars

Recent Tags See all

v0.6.0 September 15, 2019
v0.5.0 January 22, 2019
v0.4.0 January 21, 2019
v0.3.0 December 15, 2018
v0.2.1 December 11, 2018
0.2.0 December 09, 2018
v0.1.0 December 09, 2018

Something wrong with this page? Make a suggestion

Last synced: 2019-09-15 15:31:11 UTC

Login to resync this repository