colors for file types
nkh opened this issue · 11 comments
given a file path, rseturn the color codes for the type
given a file path, return the colored string
return all colors code for all types
I feel like these requests (this one and #67) are out of the scope of this repo.
I thought this was a way to access LS_COLORS which is also used for file types. If you prefer to not implement this, then you can ignore this request and the other one I wrote, I'll write my own module but I think it is a pity to start an equivalent project, specially as the other users could profit of this too.
Here is an example of how I use it. sometimes the files listed are executable, displaying them in the right color would be a good cue.
We set LS_COLORS here, but we haven't provided any interface for polling LS_COLORS. Nor do I think we need to provide one, really; anyone who wants to can parse the environment variables.
@trapd00r can disagree with me here.
@nkh what command do you use to generate the output in this image?
https://i.imgur.com/2c2U39c.png
(backup in case the imgur file disappears)
Thanks
James
hmm, probably something I wrote myself. I can dig it out. actually the output of two programs I wrote myself, one that does 'du' style computation and one that puts the colors on it.
tdu:
https://gist.github.com/nkh/3e2205e0162eacfea3e77acacb934cd3
piper:
https://gist.github.com/nkh/b7ff0bc3426842f89438507b049fe5fe
bash function containing the color for piper
piper_color_du ()
{
piper $@ '^\s*\d+B' rgb105 '^\s*[5-9]\d{2}(.\d+)?K' rgb033 '^\s*[1-4]\d{2}(.\d+)?K' rgb023 '^\s*\d{2}(.\d+)?K' rgb013 '^\s*\d(.\d+)?K' rgb003 '^\s*[5-9]\d{2}(.\d+)?M' rgb040 '^\s*[1-4]\d{2}(.\d+)?M' rgb030 '^\s*\d{2}(.\d+)?M' rgb020 '^\s*\d(.\d+)?M' rgb010 '^\s*[5-9]\d{2}(.\d+)?G' rgb540 '^\s*[1-4]\d{2}(.\d+)?G' rgb530 '^\s*\d{2}(.\d+)?G' rgb520 '^\s*\d(.\d+)?G' rgb510 '^\s\d+(.\d+)?[TP]' 'yellow on_red' '.+' grey15 '$' reset
}
used like this:
tdu | piper_color_du
thanks v much
Hi @trapd00r,
there is no bin/ls_color*, not in the master branch nor the japh branch.
the only script I find in bin/ is one that creates files with the extensions LSCOLOR defines.
did I misunderstand you?
Hm, github somehow screwed up the linking. Here, @nkh - https://github.com/trapd00r/File-LsColor