add session info to open sessions

This commit is contained in:
Daylin Morgan 2024-12-13 12:03:12 -06:00
parent 4781865071
commit 7a47942520
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -71,6 +71,15 @@ func projectFromSession(s: TmuxSession): Project =
result.tmuxinfo = s.info result.tmuxinfo = s.info
proc addInfo(project: var seq[Project]) =
## naive fix to adding tmuxinfo until I rewrite findProjects
let sessions = collect:
for s in tmux.sessions:
{s.name: s}
for p in project.mitems:
if p.name in sessions:
p.tmuxinfo = sessions[p.name].info
proc findProjects*(open: bool = false): seq[Project] = proc findProjects*(open: bool = false): seq[Project] =
let tsmConfig = loadTsmConfig() let tsmConfig = loadTsmConfig()
@ -117,10 +126,11 @@ proc findProjects*(open: bool = false): seq[Project] =
if sessions.len > 0: if sessions.len > 0:
result = tmux.sessions.filterIt(it.name in sessions).mapIt(projectFromSession(it)) & result result = tmux.sessions.filterIt(it.name in sessions).mapIt(projectFromSession(it)) & result
# result = sessions.toSeq().mapIt(newUnknownProject(it)) & result
if len(result) == 0: if len(result) == 0:
termError "nothing to select, check your [yellow]$TSM_PATHS" termError "nothing to select, check your [yellow]$TSM_PATHS"
termEcho "searched these directories: " termEcho "searched these directories: "
echo getTsmDirs().mapIt(" " & it).join("\n") echo getTsmDirs().mapIt(" " & it).join("\n")
quit QuitFailure quit QuitFailure
addInfo result