-
-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathtmuxinator.go
More file actions
45 lines (38 loc) · 1.07 KB
/
Copy pathtmuxinator.go
File metadata and controls
45 lines (38 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package lister
import (
"fmt"
"github.com/joshmedeski/sesh/v2/model"
)
func tmuxinatorKey(name string) string {
return fmt.Sprintf("tmuxinator:%s", name)
}
func listTmuxinator(l *RealLister) (model.SeshSessions, error) {
tmuxinatorResults, err := l.tmuxinator.List()
if err != nil {
return model.SeshSessions{}, fmt.Errorf("couldn't list tmuxinator sessions: %q", err)
}
numTmuxinatorResults := len(tmuxinatorResults)
orderedIndex := make([]string, numTmuxinatorResults)
directory := make(model.SeshSessionMap)
for i, session := range tmuxinatorResults {
key := tmuxinatorKey(session.Name)
orderedIndex[i] = key
directory[key] = model.SeshSession{
Src: "tmuxinator",
Name: session.Name,
}
}
return model.SeshSessions{
Directory: directory,
OrderedIndex: orderedIndex,
}, nil
}
func (l *RealLister) FindTmuxinatorConfig(name string) (model.SeshSession, bool) {
sessions, _ := listTmuxinator(l)
key := tmuxinatorKey(name)
if session, exists := sessions.Directory[key]; exists {
return session, exists
} else {
return model.SeshSession{}, false
}
}