sharkdp / lscolors

A Rust library and tool to colorize paths using LS_COLORS
Apache License 2.0
265 stars 18 forks source link

Feature request: option to return a substring of the colored file name #33

Closed nkh closed 3 years ago

nkh commented 3 years ago

Hi, I'd be cool to have these features:

"some input" | lscolors --length 10 --strip_start would output the input colored with a length of maximum of 10 characters, removing excess characters att the beginning of the input

"some input" | lscolors --length 10 --strip_end would output the input colored with a length of maximum of 10 characters , removing excess characters att the end of the input

a much fancy interface would be with a --printf so one could do something like :

stat somefile --printf "%x\t%f%y" | lscolors -d '\t' -printf "%5s %10lscolors_strip-end %s"

where %lscolors_strip_end is lscolors specific, it allows coloring of multiple files in the same input if wanted by the user and is a simple way to define a colorizer for stat or other commands listing files.

All this is to simplify short scripts, and make stat output a tad less dull in colored terminals, and can of course be dealt with outside lscolors

sharkdp commented 3 years ago

I'm sorry, but this sounds far too specific. lscolors (this repository) is mostly a library. The lscolors command line tool is just provided as an example. Everyone is welcome to build more complex tools with that library.