colors: support for hidden files and folders#2492
colors: support for hidden files and folders#2492slavshik wants to merge 5 commits intogokcehan:masterfrom
Conversation
|
Regarding dotfiles, this is what the man page of At least for colors, How do your patterns look like when used inside Also worth mentioning is that we explicitly don't support real globbing due to performance implications. |
|
Good point. To avoid any ambiguity with the This approach:
|
There was a problem hiding this comment.
I am not sure about this. I admit this is a rather simple fix. However, this seems like a pretty specific use-case.
Do you know about other tools that support this? I am kinda against inventing a new syntax just for this. However, I do get that you probably don't want to add dozens of filenames to your config, to work around this.
Something else to consider: lf has special logic to determine hidden files on Windows. If we were to add this, you should probably consider using isHidden.
Also: What about icons?
Not sure how related that is, but there are long standing issues about executable icons overwriting others. I compared joshuto, eza, lsd and lf. In terms of colouring, their behaviour seems to match (i.e. following LS_COLORS/ls in terms of precedence). For icons there is no de facto standard as this was not considered back then. However, besides lf, name and suffix matches always seem to take precedence over file type matches.
I actually considered changing the matching priority for icons, so names and suffixes match first. I only wanted to do that for icons, not colours, as this seems to be the way, other established tools do it.
Just wanted to mention that. If you are interested in this, you can read more about this topic and proposed other solutions here:
Changing the matching priority and your feature request are different but also related topics, so I wanted to link this here.
And as always, I would also like to hear @joelim-work's opinion on this PR.
|
The rules for matching files in |
|
@CatsDeservePets, @joelim-work Thank you for the feedbacks! Regarding the origin of this feature idea – I've seen it in nvim oil plugin and found it nice:
I've tried to use and my config for hiddens looks like this: |
I see I see. I do admit that I kinda like the look. Its what GUI file managers like
I'd be surprised if it didn't. Most importantly, it also respects the
I tested it by putting these into my So I don't think this is the right approach. Something I could imagine is a new option like So overall, I see the appeal of such an option but I am not sure how many people would actually use it. |
Good call —
Both default to Example config: See c5c86dc |
|
Personally, I still think this should live inside @@ -321,7 +321,12 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
visualSelections := dir.visualSelections()
for i, f := range dir.files[beg:end] {
- st := dirStyle.colors.get(f)
+ var st tcell.Style
+ if gOpts.hiddenfmt != "" && isHidden(f, f.path, gOpts.hiddenfiles) {
+ st = parseEscapeSequence(gOpts.hiddenfmt)
+ } else {
+ st = dirStyle.colors.get(f)
+ }
if lnwidth > 0 {
var ln stringBut the bigger question remains: Should it be merged? |
…t option Replace separate hiddendirfmt and hiddenfilefmt options with a single hiddenfmt option, and move the hidden colour logic from colors.go into printDir in ui.go per reviewer feedback on gokcehan#2492.
|
Hey @CatsDeservePets |
I don't want to decide this without @joelim-work. However, I think he might say that this is something that could be added using: |
|
Hi @slavshik, @CatsDeservePets Thank you for your work and interest on this. I agree that the current syntax (based on If there is significant demand for this from other users, then I will reconsider. But for now you can just manually specify each name directly (i.e. |


Closes #2493
Summary
Add support for
.*and.*/as special color patterns that match any dotfile or dotfolder respectively.Problem: lf's color lookup works by constructing a lookup key from the filename (e.g. for
.gitconfigit checks.gitconfig*,*.gitconfig, etc.) and doing an exact map lookup. This makes it impossible to write a single pattern that matches all dotfiles — there is no key that would be generated for every file starting with..Solution: Two targeted checks added to
get()incolors.go:key == "di"): before returning thedistyle, check if.*/or.*is in the styles map and return that instead..*is in the styles map before falling back tofi.Priority behavior:
name/patterns still win (highest priority)ln,ex,tw,ow,st, etc.) are unaffected — onlydiand plain files are overridden.gitconfig*,*.conf) take precedence over.*.*applies to both dotfiles and dotdirs (as fallback when.*/is not set)Example usage in colors file: