Hi. New XYplorer user here, and I'm trying out the various features. I like the color filter options, but am wondering if it is possible to create a filter that colors a folder based on the presence of a CHILD folder. For example, I'd like to color Git directories based on whether there is a child /.git folder present.
I can see that it's trivial to color code the /.git folder itself. Again, what I'd like to do is color code the PARENT folder if that folder contains a /.git folder. Hopefully that makes sense?
Thanks,
Brian
Color filter based on child folder match?
Re: Color filter based on child folder match?
Hello and welcome to the club!
It makes perfect sense and is a great idea but unfortunately not currently easily achievable.
There's some alternatives though...
At one point I was using the last one to mark repositories but admittedly that was years ago and the non-automated process allowed me to get lazy.
It makes perfect sense and is a great idea but unfortunately not currently easily achievable.
There's some alternatives though...
- If you use TortoiseGit (or a similar shell extension) you can get the icon overlays to show in XYplorer by enabling them in Tools > Configuration > General > Refresh, Icons, History > Icons > Show icon overlays.
- Tagging and Property Based color filters.
- Select the parent folder and tag it with something like 'git-repo'.
- Create a color filter with this pattern:Surrounding the tag with '*...*' ensures it matches if you assign multiple tags to the item.
Code: Select all
prop:#tags:*git-repo*
- Use Highlighting to color the item in the tree - go to the folder and select Favorites -> Set Highlight Color.
- Use Boxing to color the item & children in the tree plus change the list background color - go to the folder and select Favorites -> Set Box Color.
At one point I was using the last one to mark repositories but admittedly that was years ago and the non-automated process allowed me to get lazy.
Re: Color filter based on child folder match?
Thanks for the reply! Sounds like a decent idea for an ER. :-)
Yeah, I have the icon overlays turned off because they seemed to cause more performance problems than they were worth (at least with vanilla Explorer). Maybe I try turn them back on again and see if XYplorer handles it better.
The tagging idea is also an option, but ideally I'd like something automatic, rather than something requiring me to go tag git repos manually.
I'm really digging this tool though. I had long ago given up on Explorer and have tried QTTabBar and CubicExplorer. But as open-source / single-developer projects, they're just not quite up to par. As a developer who's using a file view all day, I'm happy to pay for something that's really well done and maintained.
Yeah, I have the icon overlays turned off because they seemed to cause more performance problems than they were worth (at least with vanilla Explorer). Maybe I try turn them back on again and see if XYplorer handles it better.
The tagging idea is also an option, but ideally I'd like something automatic, rather than something requiring me to go tag git repos manually.
I'm really digging this tool though. I had long ago given up on Explorer and have tried QTTabBar and CubicExplorer. But as open-source / single-developer projects, they're just not quite up to par. As a developer who's using a file view all day, I'm happy to pay for something that's really well done and maintained.
Re: Color filter based on child folder match?
You can also use this CustomColumn script as a replacement of colorfilter. When added to list, this column will show 'Yes' for folders matching the criteria.
Enter ::snippet; in the addressbar, paste the code in the opened dialog.Now right click on the 'name' column header, select 'new column'. Right click again on the new column header, choose 'select custom columb' and select '.\git exists'.
Stay tuned, I have an idea about auto-colorfiltering... will see when I'm awake again.
Enter ::snippet; in the addressbar, paste the code in the opened dialog.
Code: Select all
Snip: CustomColumn 1
XYplorer 14.40.0318, 9/16/2014 10:45:56 PM
Action
ConfigureColumn
Caption
.git\ exists
Type
3
Definition
if (exists("<cc_item>\.git") == 2){
return 'yes';
}
Format
0
Trigger
1
Item Type
1
Item Filter
Stay tuned, I have an idea about auto-colorfiltering... will see when I'm awake again.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Color filter based on child folder match?
Some more options based on Instant Color Filters[/i] and [url=http://www.xyplorer.com/release_13.90.h ... bleColumns]Scriptable Custom Columns.
1) You can use the tag and box approaches I previously mentioned but use a custom column to automatically tag your repositories. Use the snippet command Sammay mentioned but paste this instead:You'll also need a color filter for the 'git-repo' tag:Because scripting columns can be a bit slow and have a negative impact on listing this script only runs when the list is showing a listing containing a ".git" folder, meaning it isn't fully automatic.
Thus, if you have, C:\Projects\TopSecret\.git until you browse C:\Projects\TopSecret it won't be highlighted, but once you do browse it the script will tag and box the path so that in the future it is colored.
The script also doesn't return anything so the column that is displayed is left blank and is otherwise useless, but it can be modified to do more or show something useful if desired.
2) The fully automatic approach using Instant Color Filters... Again do the snippet thing but use this:This one color the folders automatically as you browse, however as mentioned in the previous point this can impact performance. That said, one advantage to this is it is easier to modify it to handle multiple patterns (hopefully the comments are clear enough), but take care since the more patterns there are the longer it may take. (There is probably room for optimization with this script.)
You also might be tempted to switch this custom column to trigger on List instead of Browse but currently that seems to cause XY to crash.
Personally I'm partial to, and plan on using, the first one since it is a little lighter overall. The lack of full automation isn't ideal but doing a search for all your ".git" folders and displaying the column will tag them all in one go so you only have to worry about new repositories, which you'll likely enter at some point anyhow.
It also has the added bonus that you can then search by the 'git-repo' tag which can be quicker than having XY search the file system.
Hope that helps you out and thank you for asking the original question without which I might not have looked into automating this.
1) You can use the tag and box approaches I previously mentioned but use a custom column to automatically tag your repositories. Use the snippet command Sammay mentioned but paste this instead:
Code: Select all
Snip: CustomColumn 1
XYplorer 14.40.0318, 9/16/2014 3:54:01 PM
Action
ConfigureColumn
Caption
Auto-Tagger
Type
3
Definition
$path = Trim(<cc_path>, '\/');
Box 'BBDDBB', $path;
Tag 'git-repo', $path, 1, 0;
Format
0
Trigger
0
Item Type
1
Item Filter
".git"Code: Select all
prop:#tag:*git-repo*Thus, if you have, C:\Projects\TopSecret\.git until you browse C:\Projects\TopSecret it won't be highlighted, but once you do browse it the script will tag and box the path so that in the future it is colored.
The script also doesn't return anything so the column that is displayed is left blank and is otherwise useless, but it can be modified to do more or show something useful if desired.
2) The fully automatic approach using Instant Color Filters... Again do the snippet thing but use this:
Code: Select all
Snip: CustomColumn 1
XYplorer 14.40.0318, 9/16/2014 4:02:05 PM
Action
ConfigureColumn
Caption
AICF
Type
3
Definition
// Permanent Variable - On/Off Switch
if ($P_CC_DISABLE_ALL && $P_CC_DISABLE_ALL != '$P_CC_DISABLE_ALL') {
return 'CC Disabled';
}
/*******************************************************************************
This is a list of patterns to match against. Each line is a single pattern and
should be of the form:
pattern|textColorRRGGBB,backColorRRGGBB|Display Value
The pattern is used in two ways:
1) Passed to ListFolder to check for children matching this pattern.
In this case NoAutoWildcards is enabled to allow for exact matches, so
if you want a wildcard match make sure you include them.
dog = Checks for item named 'dog'.
*dog* = Checks for items whose name contains 'dog'
2) Compared against the name of the row's item using 'LikeI'.
This allows for highlighting the folder itself when $colorSelf is true.
*******************************************************************************/
$patterns = <<<PATTERNS
.git|,F4274D|Git
.hg|,999999|Mercurial
.svn|,97D5AF|Subversion
CVS|,FF0000|Oh Hell...
PATTERNS;
// Color Self: Compares the pattern against the row item when set to true.
$colorSelf = true;
// Clean up the patterns list.
$patterns = FormatList($patterns, 'ted', "<crlf>");
// Loop through patterns - not terribly efficient.
foreach ($line, $patterns, "<crlf>") {
$line = Trim($line, " <tab>");
if ($line == '') { continue; }
// Check this pattern.
$pattern = GetToken($line, 1, '|', 't');
$selfMatches = $colorSelf ? (<cc_name> LikeI "$pattern") : false;
// Skip getting contents where possible.
if (! $selfMatches) {
$count = listfolder(<cc_item>, $pattern, 8+32);
} else {
$count = 0;
}
// If a match...
if ($selfMatches || ($count != '' && $count > 0)) {
// Add Instant Color Filter
$clr = GetToken($line, 2, '|', 't');
$cf = ColorFilter();
ColorFilter($cf . "||" . "+*<cc_item>>$clr");
// Return comment.
$com = GetToken($line, 3, '|', 't', 2);
return $com;
}
}
Format
0
Trigger
0
Item Type
1
Item Filter
You also might be tempted to switch this custom column to trigger on List instead of Browse but currently that seems to cause XY to crash.
Personally I'm partial to, and plan on using, the first one since it is a little lighter overall. The lack of full automation isn't ideal but doing a search for all your ".git" folders and displaying the column will tag them all in one go so you only have to worry about new repositories, which you'll likely enter at some point anyhow.
Hope that helps you out and thank you for asking the original question without which I might not have looked into automating this.
-
admin
- Site Admin
- Posts: 64861
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Color filter based on child folder match?
Wow, what a fascinating way to tell me that there should be something easier to achieve this. 
FAQ | XY News RSS | XY X
XYplorer Beta Club