TritonDataCenter / node-manta

Node.js SDK for Manta
75 stars 54 forks source link

want color output for mls like ls #351

Open bahamas10 opened 6 years ago

bahamas10 commented 6 years ago

I'd have to look more into how ls handles it (and how various version of ls handle it)... but I know off the top of my head there is LS_COLORS and LSCOLORS available as env variables... it would be cool if mls could use these variables if set, or have its own MLSCOLORS, and output color if stdout is a TTY.

jasonbking commented 6 years ago

GNU ls just takes the values and essentially spits out the control sequences. If you split the LS_COLORS value by semicolon, then you want to print the 'lc' value (default is '\e[', then the value for whatever filetype (no, or a glob match), then the 'rc' value (default is 'm', the filename, then the 'ec' value (I think the default is '\e[0m'.

jasonbking commented 6 years ago

BSD is completely different of course. illumos doesn't assume all the world is xterm, and converts the LS_COLORS sequences back to color codes and then uses the terminfo database to output the correct sequence.

bahamas10 commented 6 years ago

^ Interesting.... so it appears they all do something different. hm. If node-manta is to support this, I definitely want it done right and not make any assumptions if we can avoid it.

jasonbking commented 6 years ago

You could probably go off the existence of either LSCOLOR (BSD) or LS_COLORS (GNU) and prefer which ever one is 'native' if both env vars are present.