Help to colorize file names in subprocess mode

8 views
Skip to first unread message

Bob Hyman

unread,
Dec 8, 2019, 1:48:52 AM12/8/19
to xonsh
Hi All,
I have an idea to color filenames that appear as arguments in subprocess mode using the same colors as `ls -c` would do, based on the color values already populated in LS_COLORS.  
I found the place in `xonsh/pyghooks` where an argument is tagged as Token.Name.Constant if it is a valid path and as Text if not.  
If I replace that with Token.Color.INTENSE_CYAN, the path is colored cyan, but if I replace it with Token.Color.BOLD_CYAN, it is not colored.  
I see that INTENSE_CYAN is included in my current color style (pyghooks._default_style()), but BOLD_CYAN is not, and I guess that's why it is filtered out.  
But LS_COLORS is full of BOLD_xxx colors and backgrounds that aren't in my style. 

Can you confirm what the restriction actually is?  And, can you suggest a smart way to go about extending it!  
Ideally, I'd be able to add arbitrary colors from LS_COLORS, converted into Token.Color..., into the style, rather than trying to map them through existing style colors.  
Rationale:  the user is familar with the LS_COLORS file coloring and probably wouldn't recognize what's happening if the style maps them to arbitrary other colors. Plus, I have a working file classifier that returns a Token.Color value for all the file type keys in LS_COLORS, so I feel like maybe I'm close.

On a side note, I don't see any references to values in LS_COLORS anywhere in XONSH after initialization.  It looks like the only purpose LS_COLORS currently serves is as a proxy you can modify to affect the LS_COLORS in the outer shell environment.  Are there plugins that depend on it?  Or am I just missing the real story?

Regards,
Bob
Reply all
Reply to author
Forward
0 new messages