cafehaine / xontrib-xlsd

xontrib-xlsd is the next gen ls command for xonsh shell, inspired by lsd.
GNU General Public License v3.0
21 stars 4 forks source link

LS_COLORS Support #11

Closed scopatz closed 3 years ago

scopatz commented 3 years ago

I realized what else was causing me issues here. Basically, this does not support LS_COLORS, so all file types come out with the same base text color. This should be relatively easy to add with the use of $LS_COLORS, which is a special mapping in xonsh from globs to xonsh color names, and the use of xonsh.tools.print_color() or format_color().

cafehaine commented 3 years ago

I guess that shouldn't be that hard to implement, will look into it!

scopatz commented 3 years ago

Cool thanks!

cafehaine commented 3 years ago

@scopatz From what I can see, the xonsh colors don't allow specifying a modifier without a color. This prevents me from doing my current rules like "executables are bold" while keeping the default color of the shell.

I had the idea of specifying modifiers instead of ANSI escape codes, but that would remove the possibility of for example making symbolic links blue.

Do you know of a way I could properly handle this ?

Or maybe allow multiple color selection scheme, one using my current rules with ANSI escape codes, and another one using xonsh colors + $LS_COLORS, but that will be quite a lot of code to manage.

scopatz commented 3 years ago

Yeah, I think we probably need to add just the modifiers to xonsh

cafehaine commented 3 years ago

Will be much easier to implement now that 2cdf19ed9bb74cc7c16b97325997cda9944ef4e7 is pushed: xlsd now uses standard xonsh color codes instead of ansi escape codes.

scopatz commented 3 years ago

Awesome!

cafehaine commented 3 years ago

LS_COLORS should be supported since 7f7378ede21754bf31374aa479066db18ff502ac, please try it out and let me know!

scopatz commented 3 years ago

Thanks @cafehaine! I have tried it out and it seems as though all the filenames are still in black and white. I am using the default $LS_COLORS from xonsh

cafehaine commented 3 years ago

The executable and symlink colors were applied after the LS_COLORS, which means that the colors from LS_COLORS were overwritten. I've now changed the order so that LS_COLORS has priority over the executable/symlink styling.

Let me know if it still doesn't work after 6e411a2!

scopatz commented 3 years ago

Huh, strange. I updated to 6e411a2 and it still isn't showing any colors. Anything I can do to help debug? I tripple checked that I am using the correct version

cafehaine commented 3 years ago

I'm not sure, what backend are you using when testing? I've only really tested with PTK but readline shoudn't cause any problem

Maybe you could add a print at line 206 in xlsd.xsh to see if any colors are applied?

Not sure what else could cause this.

cafehaine commented 3 years ago

I think I found the issue, I'm only applying the extension styling, but not the styling using fi, ln, and other file types.

So maybe that's what missing for you, I'll try to make that work.

scopatz commented 3 years ago

Ahh yeah that is probably what is going on. I am just testing in my home dir and in the xonsh repo

cafehaine commented 3 years ago

I think I've finally got the expected result in 8a4583a, could you try this commit out?

scopatz commented 3 years ago

Amazing! It works! Thanks so much!!