Skip to content

Commit dcf7bca

Browse files
author
xujinkai
committed
Support <&&> Match
1 parent 38ee70d commit dcf7bca

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ Plus, `%DIR%` stands for current folder.
2525
### Match
2626

2727
- If not null, checks if current folder have the name (file or directory)
28-
- Starts by ! for NOT have the name
29-
- use ? and * for wildcard
28+
- Splits conditions by **<&&>**
29+
- Starts by **!** for reverse condition
30+
- Use **?** and ***** for wildcard
3031

3132
### Icon
3233

ShellCommand/DataModel/DirectoryCommand.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ public bool IsMatch(string workingDir)
5151
if (string.IsNullOrEmpty(Match))
5252
return true;
5353

54-
bool reverse = false;
55-
string pattern = Match;
56-
if (Match.StartsWith("!"))
54+
bool result = true;
55+
foreach (var split in Match.Split(new string[] { "<&&>" }, StringSplitOptions.RemoveEmptyEntries))
5756
{
58-
reverse = true;
59-
pattern = Match.Substring(1);
57+
var pattern = split;
58+
bool reverse = false;
59+
if (pattern.StartsWith("!"))
60+
{
61+
reverse = true;
62+
pattern = pattern.Substring(1);
63+
}
64+
var exist = Directory.GetFiles(workingDir, pattern).Any() || Directory.GetDirectories(workingDir, pattern).Any();
65+
result &= exist ^ reverse;
6066
}
61-
62-
var exist = Directory.GetFiles(workingDir, pattern).Any() || Directory.GetDirectories(workingDir, pattern).Any();
63-
return exist ^ reverse;
67+
return result;
6468
}
6569

6670
public ToolStripItem ToMenuItem(string workingDir)

ShellCommand/global.template.shellcommand.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ GlobalCommands:
1414
Match: .gitmodules
1515
Icon: "%PROGRAMFILES%/Git/git-cmd.exe"
1616

17+
- Name: Create README.md
18+
Command: cmd /c copy nul README.md
19+
Match: ".git<&&>!README.md"
20+
Icon: "%SystemRoot%/System32/Shell32.dll?70"
21+
1722
- Name: ---
1823

1924
- Name: Open Command Window Here(&C)
2025
Command: cmd
21-
Icon: C:/WIndows/System32/cmd.exe
26+
Icon: "%SystemRoot%/System32/cmd.exe"
2227

2328
- Name: Open Command Window Here (Administrator)(&A)
2429
Command: cmd /K "cd /d ""%DIR%"""
2530
RunAsAdmin: true
26-
Icon: C:/WIndows/System32/cmd.exe
31+
Icon: "%SystemRoot%/System32/cmd.exe"
2732

2833
- Name: ---
2934

0 commit comments

Comments
 (0)