Skip to content

Commit b766fd7

Browse files
bdefermeBert DEFERME
andauthored
˝✨ Support regex in blacklist (#239)
Co-authored-by: Bert DEFERME <[email protected]>
1 parent 3163020 commit b766fd7

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

lister/blacklist.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
package lister
22

3-
import "strings"
3+
import "regexp"
44

55
func isBlacklisted(blacklist []string, name string) bool {
66
for _, blacklistedName := range blacklist {
7-
if strings.EqualFold(blacklistedName, name) {
7+
if regexp.MustCompile(blacklistedName).MatchString(name) {
88
return true
99
}
1010
}
1111
return false
1212
}
13-
14-
func createBlacklistSet(blacklist []string) map[string]struct{} {
15-
blacklistSet := make(map[string]struct{}, len(blacklist))
16-
for _, name := range blacklist {
17-
blacklistSet[name] = struct{}{}
18-
}
19-
return blacklistSet
20-
}

lister/tmux.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ func listTmux(l *RealLister) (model.SeshSessions, error) {
1616
return model.SeshSessions{}, fmt.Errorf("couldn't list tmux sessions: %q", err)
1717
}
1818

19-
blacklistSet := createBlacklistSet(l.config.Blacklist)
2019
directory := make(map[string]model.SeshSession)
2120
orderedIndex := []string{}
2221

2322
for _, session := range tmuxSessions {
24-
if _, blacklisted := blacklistSet[session.Name]; !blacklisted {
23+
if !isBlacklisted(l.config.Blacklist, session.Name) {
2524
key := tmuxKey(session.Name)
2625
orderedIndex = append(orderedIndex, key)
2726
directory[key] = model.SeshSession{

0 commit comments

Comments
 (0)