File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11package tmux
22
33import (
4+ "sort"
45 "strings"
56 "time"
67
@@ -119,7 +120,7 @@ func List() ([]*TmuxSession, error) {
119120 for _ , line := range lines {
120121 fields := strings .Split (line , " " ) // Strings split by single space
121122 if len (fields ) == 21 {
122- sessions = append ( sessions , & TmuxSession {
123+ session := & TmuxSession {
123124 Activity : convert .StringToTime (fields [0 ]),
124125 Alerts : convert .StringToIntSlice (fields [1 ]),
125126 Attached : convert .StringToInt (fields [2 ]),
@@ -141,6 +142,12 @@ func List() ([]*TmuxSession, error) {
141142 Path : fields [18 ],
142143 Stack : convert .StringToIntSlice (fields [19 ]),
143144 Windows : convert .StringToInt (fields [20 ]),
145+ }
146+ if session .Attached != 1 {
147+ sessions = append (sessions , session )
148+ }
149+ sort .Slice (sessions , func (i , j int ) bool {
150+ return sessions [j ].LastAttached .Before (* sessions [i ].LastAttached )
144151 })
145152 }
146153 }
You can’t perform that action at this time.
0 commit comments